Skip to content

Commit

Permalink
fixed meal type constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Feb 5, 2024
1 parent e530396 commit 7e39e6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cookbook/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ def user(obj):


class MealTypeAdmin(admin.ModelAdmin):
list_display = ('name', 'created_by', 'order')
search_fields = ('name', 'created_by__username')
list_display = ('name', 'space', 'created_by', 'order')
search_fields = ('name', 'space', 'created_by__username')


admin.site.register(MealType, MealTypeAdmin)
Expand Down
2 changes: 1 addition & 1 deletion cookbook/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def create(self, validated_data):
validated_data['name'] = validated_data['name'].strip()
space = validated_data.pop('space', self.context['request'].space)
validated_data['created_by'] = self.context['request'].user
obj, created = MealType.objects.get_or_create(name__iexact=validated_data['name'], space=space, defaults=validated_data)
obj, created = MealType.objects.get_or_create(name__iexact=validated_data['name'], space=space, created_by=self.context['request'].user, defaults=validated_data)
return obj

class Meta:
Expand Down

0 comments on commit 7e39e6f

Please sign in to comment.