From b30f8c245e11993d5450c2dfd2edf92021284d9d Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 22 Jul 2023 09:12:45 +0200 Subject: [PATCH] added option to set URL on food --- cookbook/migrations/0196_food_url.py | 18 +++++++++ cookbook/models.py | 1 + cookbook/serializer.py | 2 +- vue/src/components/FoodEditor.vue | 5 +++ vue/src/components/IngredientComponent.vue | 45 +++++++++++++--------- 5 files changed, 51 insertions(+), 20 deletions(-) create mode 100644 cookbook/migrations/0196_food_url.py diff --git a/cookbook/migrations/0196_food_url.py b/cookbook/migrations/0196_food_url.py new file mode 100644 index 00000000..aef8c595 --- /dev/null +++ b/cookbook/migrations/0196_food_url.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.10 on 2023-07-22 06:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0195_invitelink_internal_note_userspace_internal_note_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='food', + name='url', + field=models.CharField(blank=True, default='', max_length=1024, null=True), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 5a931024..f4369c70 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -579,6 +579,7 @@ class Food(ExportModelOperationsMixin('food'), TreeModel, PermissionModelMixin): name = models.CharField(max_length=128, validators=[MinLengthValidator(1)]) plural_name = models.CharField(max_length=128, null=True, blank=True, default=None) recipe = models.ForeignKey('Recipe', null=True, blank=True, on_delete=models.SET_NULL) + url = models.CharField(max_length=1024, blank=True, null=True, default='') supermarket_category = models.ForeignKey(SupermarketCategory, null=True, blank=True, on_delete=models.SET_NULL) # inherited field ignore_shopping = models.BooleanField(default=False) # inherited field onhand_users = models.ManyToManyField(User, blank=True) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index c867b2a6..28a348e1 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -684,7 +684,7 @@ class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer, ExtendedR class Meta: model = Food fields = ( - 'id', 'name', 'plural_name', 'description', 'shopping', 'recipe', + 'id', 'name', 'plural_name', 'description', 'shopping', 'recipe', 'url', 'properties', 'properties_food_amount', 'properties_food_unit', 'food_onhand', 'supermarket_category', 'image', 'parent', 'numchild', 'numrecipe', 'inherit_fields', 'full_name', 'ignore_shopping', diff --git a/vue/src/components/FoodEditor.vue b/vue/src/components/FoodEditor.vue index f1cf6f36..232ae4bc 100644 --- a/vue/src/components/FoodEditor.vue +++ b/vue/src/components/FoodEditor.vue @@ -170,6 +170,10 @@ > + + + + {{ $t('OnHand') }} @@ -309,6 +313,7 @@ export default { description: "", shopping: false, recipe: null, + url: '', properties: [], properties_food_amount: 100, properties_food_unit: {name: 'g'}, diff --git a/vue/src/components/IngredientComponent.vue b/vue/src/components/IngredientComponent.vue index 3fc431e0..eb26b87a 100644 --- a/vue/src/components/IngredientComponent.vue +++ b/vue/src/components/IngredientComponent.vue @@ -30,21 +30,13 @@