mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-04 05:39:00 -05:00
uniqueness fixes
This commit is contained in:
23
cookbook/migrations/0121_auto_20210518_1638.py
Normal file
23
cookbook/migrations/0121_auto_20210518_1638.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.2.3 on 2021-05-18 14:38
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cookbook', '0120_bookmarklet'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='userpreference',
|
||||
name='search_style',
|
||||
field=models.CharField(choices=[('SMALL', 'Small'), ('LARGE', 'Large'), ('NEW', 'New')], default='LARGE', max_length=64),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='userpreference',
|
||||
name='use_fractions',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -177,6 +177,10 @@ class UnitSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
|
||||
def create(self, validated_data):
|
||||
obj, created = Unit.objects.get_or_create(name=validated_data['name'].strip(), space=self.context['request'].space)
|
||||
return obj
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
validated_data['name'] = validated_data['name'].strip()
|
||||
return super(UnitSerializer, self).update(instance, validated_data)
|
||||
|
||||
class Meta:
|
||||
model = Unit
|
||||
@@ -222,6 +226,7 @@ class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer):
|
||||
return obj
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
validated_data['name'] = validated_data['name'].strip()
|
||||
return super(FoodSerializer, self).update(instance, validated_data)
|
||||
|
||||
class Meta:
|
||||
|
||||
Reference in New Issue
Block a user