diff --git a/cookbook/serializer.py b/cookbook/serializer.py index 03f56c53e5..b348ae473b 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -199,7 +199,7 @@ def get_user_label(self, obj): class Meta: list_serializer_class = SpaceFilterSerializer model = User - fields = ('id', 'username', 'first_name', 'last_name', 'display_name') + fields = ('id', 'username', 'first_name', 'last_name', 'display_name', 'is_staff', 'is_superuser', 'is_active') read_only_fields = ('username',) @@ -1294,7 +1294,12 @@ class ViewLogSerializer(serializers.ModelSerializer): def create(self, validated_data): validated_data['created_by'] = self.context['request'].user validated_data['space'] = self.context['request'].space - return super().create(validated_data) + + view_log = ViewLog.objects.filter(recipe=validated_data['recipe'], created_by=self.context['request'].user, created_at__gt=(timezone.now() - timezone.timedelta(minutes=5)), space=self.context['request'].space).first() + if not view_log: + view_log = ViewLog.objects.create(recipe=validated_data['recipe'], created_by=self.context['request'].user, space=self.context['request'].space) + + return view_log class Meta: model = ViewLog diff --git a/cookbook/views/api.py b/cookbook/views/api.py index f991db85e5..e3b8221267 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -1121,6 +1121,8 @@ def get_paginated_response(self, data): description=_('Returns the results in randomized order. [''true''/''false'']')), OpenApiParameter(name='new', description=_('Returns new results first in search results. [''true''/''false'']')), + OpenApiParameter(name='num_recent', description=_( + 'Returns the given number of recently viewed recipes before search results (if given)'), type=int), OpenApiParameter(name='timescooked', description=_( 'Filter recipes cooked X times or more. Negative values returns cooked less than X times'), type=int), OpenApiParameter( diff --git a/vue3/src/apps/tandoor/Tandoor.vue b/vue3/src/apps/tandoor/Tandoor.vue index 6ca9214168..0eba137f43 100644 --- a/vue3/src/apps/tandoor/Tandoor.vue +++ b/vue3/src/apps/tandoor/Tandoor.vue @@ -62,6 +62,12 @@ {{ $t('Messages') }} + + + {{ $t('Admin') }} +