minor updates
This commit is contained in:
parent
de7d2e27d9
commit
94b2e9b01c
@ -689,7 +689,7 @@ class Comment(ExportModelOperationsMixin('comment'), models.Model, PermissionMod
|
||||
|
||||
objects = ScopedManager(space='recipe__space')
|
||||
|
||||
@ staticmethod
|
||||
@staticmethod
|
||||
def get_space_key():
|
||||
return 'recipe', 'space'
|
||||
|
||||
@ -737,7 +737,7 @@ class RecipeBookEntry(ExportModelOperationsMixin('book_entry'), models.Model, Pe
|
||||
|
||||
objects = ScopedManager(space='book__space')
|
||||
|
||||
@ staticmethod
|
||||
@staticmethod
|
||||
def get_space_key():
|
||||
return 'book', 'space'
|
||||
|
||||
@ -804,7 +804,7 @@ class ShoppingListRecipe(ExportModelOperationsMixin('shopping_list_recipe'), mod
|
||||
|
||||
objects = ScopedManager(space='recipe__space')
|
||||
|
||||
@ staticmethod
|
||||
@staticmethod
|
||||
def get_space_key():
|
||||
return 'recipe', 'space'
|
||||
|
||||
@ -837,7 +837,7 @@ class ShoppingListEntry(ExportModelOperationsMixin('shopping_list_entry'), model
|
||||
space = models.ForeignKey(Space, on_delete=models.CASCADE)
|
||||
objects = ScopedManager(space='space')
|
||||
|
||||
@ staticmethod
|
||||
@staticmethod
|
||||
def get_space_key():
|
||||
return 'shoppinglist', 'space'
|
||||
|
||||
@ -1010,7 +1010,7 @@ class SearchFields(models.Model, PermissionModelMixin):
|
||||
def __str__(self):
|
||||
return _(self.name)
|
||||
|
||||
@ staticmethod
|
||||
@staticmethod
|
||||
def get_name(self):
|
||||
return _(self.name)
|
||||
|
||||
|
@ -78,7 +78,7 @@ class CustomDecimalField(serializers.Field):
|
||||
def to_representation(self, value):
|
||||
if not isinstance(value, Decimal):
|
||||
value = Decimal(value)
|
||||
return round(value, 3).normalize()
|
||||
return round(value, 2).normalize()
|
||||
|
||||
def to_internal_value(self, data):
|
||||
if type(data) == int or type(data) == float:
|
||||
@ -166,7 +166,7 @@ class UserPreferenceSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = UserPreference
|
||||
fields = (
|
||||
'user', 'theme', 'nav_color', 'default_unit', 'default_page',
|
||||
'user', 'theme', 'nav_color', 'default_unit', 'default_page', 'use_kj',
|
||||
'search_style', 'show_recent', 'plan_share', 'ingredient_decimals',
|
||||
'comments', 'shopping_auto_sync', 'mealplan_autoadd_shopping', 'food_ignore_default', 'default_delay',
|
||||
'mealplan_autoinclude_related', 'mealplan_autoexclude_onhand', 'shopping_share', 'shopping_recent_days'
|
||||
@ -335,9 +335,6 @@ class SupermarketCategorySerializer(UniqueFieldsMixin, WritableNestedModelSerial
|
||||
class SupermarketCategoryRelationSerializer(WritableNestedModelSerializer):
|
||||
category = SupermarketCategorySerializer()
|
||||
|
||||
def get_fields(self, *args, **kwargs):
|
||||
return super().get_fields(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
model = SupermarketCategoryRelation
|
||||
fields = ('id', 'category', 'supermarket', 'order')
|
||||
@ -543,9 +540,6 @@ class RecipeSerializer(RecipeBaseSerializer):
|
||||
validated_data['space'] = self.context['request'].space
|
||||
return super().create(validated_data)
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
return super().update(instance, validated_data)
|
||||
|
||||
|
||||
class RecipeImageSerializer(WritableNestedModelSerializer):
|
||||
class Meta:
|
||||
@ -675,22 +669,11 @@ class ShoppingListEntrySerializer(WritableNestedModelSerializer):
|
||||
|
||||
def get_fields(self, *args, **kwargs):
|
||||
fields = super().get_fields(*args, **kwargs)
|
||||
# try:
|
||||
# # this serializer is the parent serializer for the API
|
||||
# api_serializer = self.context['view'].serializer_class
|
||||
# except Exception:
|
||||
# # this serializer is probably nested or a foreign key
|
||||
# api_serializer = None
|
||||
|
||||
# autosync values are only needed for frequent 'checked' value updating
|
||||
if self.context['request'] and bool(int(self.context['request'].query_params.get('autosync', False))):
|
||||
for f in list(set(fields) - set(['id', 'checked'])):
|
||||
del fields[f]
|
||||
# extended values are computationally expensive and not needed in normal circumstances
|
||||
# elif bool(int(self.context['request'].query_params.get('extended', False))) and self.__class__ == api_serializer:
|
||||
# pass
|
||||
# else:
|
||||
# del fields['recipe_mealplan']
|
||||
return fields
|
||||
|
||||
def run_validation(self, data):
|
||||
|
@ -342,7 +342,6 @@
|
||||
</div>
|
||||
|
||||
{% block script %}
|
||||
|
||||
{% endblock script %}
|
||||
|
||||
<script type="application/javascript">
|
||||
|
@ -363,7 +363,8 @@ class SupermarketCategoryViewSet(viewsets.ModelViewSet, StandardFilterMixin):
|
||||
permission_classes = [CustomIsUser]
|
||||
|
||||
def get_queryset(self):
|
||||
return self.queryset.filter(space=self.request.space)
|
||||
self.queryset = self.queryset.filter(space=self.request.space)
|
||||
return super().get_queryset()
|
||||
|
||||
|
||||
class SupermarketCategoryRelationViewSet(viewsets.ModelViewSet, StandardFilterMixin):
|
||||
|
Loading…
Reference in New Issue
Block a user