From 42faafef9f230fbdc05d62e3bc8e21ec29486c93 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Thu, 26 Dec 2019 11:32:04 +0100 Subject: [PATCH] added waiting time --- cookbook/forms.py | 10 ++++---- .../migrations/0007_auto_20191226_0852.py | 23 +++++++++++++++++++ cookbook/models.py | 3 ++- cookbook/templates/recipe_view.html | 21 +++++++++++------ cookbook/views/edit.py | 3 ++- 5 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 cookbook/migrations/0007_auto_20191226_0852.py diff --git a/cookbook/forms.py b/cookbook/forms.py index e7d0e4e4d..04e089700 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -18,12 +18,13 @@ class ExternalRecipeForm(forms.ModelForm): class Meta: model = Recipe - fields = ('name', 'keywords', 'time', 'file_path', 'storage', 'file_uid') + fields = ('name', 'keywords', 'working_time', 'waiting_time', 'file_path', 'storage', 'file_uid') labels = { 'name': _('Name'), 'keywords': _('Keywords'), - 'time': _('Preparation time in minutes'), + 'working_time': _('Preparation time in minutes'), + 'waiting_time': _('Waiting time (cooking/baking) in minutes'), 'file_path': _('Path'), 'file_uid': _('Storage UID'), } @@ -33,13 +34,14 @@ class ExternalRecipeForm(forms.ModelForm): class InternalRecipeForm(forms.ModelForm): class Meta: model = Recipe - fields = ('name', 'instructions', 'image', 'time', 'keywords') + fields = ('name', 'instructions', 'image', 'working_time', 'waiting_time', 'keywords') labels = { 'name': _('Name'), 'keywords': _('Keywords'), 'instructions': _('Instructions'), - 'time': _('Preparation time in minutes'), + 'working_time': _('Preparation time in minutes'), + 'waiting_time': _('Waiting time (cooking/baking) in minutes'), } widgets = {'keywords': MultiSelectWidget} diff --git a/cookbook/migrations/0007_auto_20191226_0852.py b/cookbook/migrations/0007_auto_20191226_0852.py new file mode 100644 index 000000000..6cb5d939a --- /dev/null +++ b/cookbook/migrations/0007_auto_20191226_0852.py @@ -0,0 +1,23 @@ +# Generated by Django 3.0.1 on 2019-12-26 07:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0006_recipe_image'), + ] + + operations = [ + migrations.RenameField( + model_name='recipe', + old_name='time', + new_name='working_time', + ), + migrations.AddField( + model_name='recipe', + name='waiting_time', + field=models.IntegerField(default=0), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 16618d902..756d79c8c 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -63,7 +63,8 @@ class Recipe(models.Model): file_path = models.CharField(max_length=512, default="") link = models.CharField(max_length=512, default="") keywords = models.ManyToManyField(Keyword, blank=True) - time = models.IntegerField(default=0) + working_time = models.IntegerField(default=0) + waiting_time = models.IntegerField(default=0) internal = models.BooleanField(default=False) created_by = models.ForeignKey(User, on_delete=models.PROTECT) created_at = models.DateTimeField(auto_now_add=True) diff --git a/cookbook/templates/recipe_view.html b/cookbook/templates/recipe_view.html index 642c8c306..3ea26678c 100644 --- a/cookbook/templates/recipe_view.html +++ b/cookbook/templates/recipe_view.html @@ -28,24 +28,30 @@ {% endif %} {% if recipe.internal %} - {% trans 'by' %} {{ recipe.created_by.username }}
+ {% trans 'by' %} {{ recipe.created_by.username }}
+
{% endif %} -
- {% if recipe.all_tags %} {{ recipe.all_tags }}

{% endif %} - {% if recipe.time and recipe.time != 0 %} - {% trans 'Preparation time ca.' %} {{ recipe.time }} min + {% if recipe.working_time and recipe.working_time != 0 %} + {% trans 'Preparation time ca.' %} {{ recipe.working_time }} min + {% endif %} + + {% if recipe.waiting_time and recipe.waiting_time != 0 %} + {% trans 'Waiting time ca.' %} {{ recipe.waiting_time }} min + {% endif %} + + {% if recipe.waiting_time and recipe.waiting_time != 0 or recipe.working_time and recipe.working_time != 0 %}

{% endif %} -
{% if ingredients %}
@@ -94,7 +100,8 @@ {% endif %} {% if recipe.image %}
- {% trans 'Recipe Image' %} + {% trans 'Recipe Image' %}

diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py index 3fd6b5fa1..52a0bae9e 100644 --- a/cookbook/views/edit.py +++ b/cookbook/views/edit.py @@ -45,7 +45,8 @@ def internal_recipe_update(request, pk): recipe = recipe_instance recipe.name = form.cleaned_data['name'] recipe.instructions = form.cleaned_data['instructions'] - recipe.time = form.cleaned_data['time'] + recipe.working_time = form.cleaned_data['working_time'] + recipe.waiting_time = form.cleaned_data['waiting_time'] if form.cleaned_data['image']: recipe.image = form.cleaned_data['image']