Skip to content

Commit

Permalink
atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
Xewus committed Mar 21, 2023
1 parent aed13ad commit 1f77b84
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.db.models import F, QuerySet
from django.db.transaction import atomic
from drf_extra_fields.fields import Base64ImageField
from recipes.models import Ingredient, Recipe, Tag
from rest_framework.serializers import ModelSerializer, SerializerMethodField
Expand Down Expand Up @@ -260,6 +261,7 @@ def validate(self, data: OrderedDict) -> OrderedDict:
})
return data

@atomic
def create(self, validated_data: dict) -> Recipe:
"""Создаёт рецепт.
Expand All @@ -276,6 +278,7 @@ def create(self, validated_data: dict) -> Recipe:
recipe_ingredients_set(recipe, ingredients)
return recipe

@atomic
def update(self, recipe: Recipe, validated_data: dict):
"""Обновляет рецепт.
Expand Down

0 comments on commit 1f77b84

Please sign in to comment.