mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
fix 977
This commit is contained in:
@@ -2,22 +2,21 @@ import random
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db.models import Avg, QuerySet, Sum
|
from django.db.models import Avg, QuerySet, Sum
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from drf_writable_nested import (UniqueFieldsMixin,
|
from drf_writable_nested import UniqueFieldsMixin, WritableNestedModelSerializer
|
||||||
WritableNestedModelSerializer)
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.exceptions import ValidationError, NotFound
|
from rest_framework.exceptions import NotFound, ValidationError
|
||||||
|
|
||||||
from cookbook.models import (Comment, CookLog, Food, Ingredient, Keyword,
|
from cookbook.models import (Automation, BookmarkletImport, Comment, CookLog, Food, ImportLog,
|
||||||
MealPlan, MealType, NutritionInformation, Recipe,
|
Ingredient, Keyword, MealPlan, MealType, NutritionInformation, Recipe,
|
||||||
RecipeBook, RecipeBookEntry, RecipeImport,
|
RecipeBook, RecipeBookEntry, RecipeImport, ShareLink, ShoppingList,
|
||||||
ShareLink, ShoppingList, ShoppingListEntry,
|
ShoppingListEntry, ShoppingListRecipe, Step, Storage, Supermarket,
|
||||||
ShoppingListRecipe, Step, Storage, Sync, SyncLog,
|
SupermarketCategory, SupermarketCategoryRelation, Sync, SyncLog, Unit,
|
||||||
Unit, UserPreference, ViewLog, SupermarketCategory, Supermarket,
|
UserFile, UserPreference, ViewLog)
|
||||||
SupermarketCategoryRelation, ImportLog, BookmarkletImport, UserFile, Automation)
|
|
||||||
from cookbook.templatetags.custom_tags import markdown
|
from cookbook.templatetags.custom_tags import markdown
|
||||||
|
|
||||||
|
|
||||||
@@ -34,9 +33,11 @@ class ExtendedRecipeMixin(serializers.ModelSerializer):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
api_serializer = None
|
api_serializer = None
|
||||||
# extended values are computationally expensive and not needed in normal circumstances
|
# extended values are computationally expensive and not needed in normal circumstances
|
||||||
if self.context.get('request', False) and bool(int(self.context['request'].query_params.get('extended', False))) and self.__class__ == api_serializer:
|
try:
|
||||||
|
if bool(int(self.context['request'].query_params.get('extended', False))) and self.__class__ == api_serializer:
|
||||||
return fields
|
return fields
|
||||||
else:
|
except AttributeError:
|
||||||
|
pass
|
||||||
del fields['image']
|
del fields['image']
|
||||||
del fields['numrecipe']
|
del fields['numrecipe']
|
||||||
return fields
|
return fields
|
||||||
|
|||||||
Reference in New Issue
Block a user