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),
|
||||||
|
),
|
||||||
|
]
|
@ -178,6 +178,10 @@ class UnitSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
|
|||||||
obj, created = Unit.objects.get_or_create(name=validated_data['name'].strip(), space=self.context['request'].space)
|
obj, created = Unit.objects.get_or_create(name=validated_data['name'].strip(), space=self.context['request'].space)
|
||||||
return obj
|
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:
|
class Meta:
|
||||||
model = Unit
|
model = Unit
|
||||||
fields = ('id', 'name', 'description')
|
fields = ('id', 'name', 'description')
|
||||||
@ -222,6 +226,7 @@ class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer):
|
|||||||
return obj
|
return obj
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
|
validated_data['name'] = validated_data['name'].strip()
|
||||||
return super(FoodSerializer, self).update(instance, validated_data)
|
return super(FoodSerializer, self).update(instance, validated_data)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -223,6 +223,19 @@ else:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Local testing DB
|
||||||
|
# DATABASES = {
|
||||||
|
# 'default': {
|
||||||
|
# 'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
# 'HOST': 'localhost',
|
||||||
|
# 'PORT': 5432,
|
||||||
|
# 'USER': 'postgres',
|
||||||
|
# 'PASSWORD': 'postgres', # set to local pw
|
||||||
|
# 'NAME': 'postgres',
|
||||||
|
# 'CONN_MAX_AGE': 600,
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
# Vue webpack settings
|
# Vue webpack settings
|
||||||
VUE_DIR = os.path.join(BASE_DIR, 'vue')
|
VUE_DIR = os.path.join(BASE_DIR, 'vue')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user