diff --git a/cookbook/forms.py b/cookbook/forms.py
index 291b2a8c..b5dca725 100644
--- a/cookbook/forms.py
+++ b/cookbook/forms.py
@@ -22,11 +22,12 @@ class ExternalRecipeForm(forms.ModelForm):
class Meta:
model = Recipe
- fields = ('name', 'keywords', 'file_path', 'storage', 'file_uid')
+ fields = ('name', 'keywords', 'time', 'file_path', 'storage', 'file_uid')
labels = {
'name': _('Name'),
'keywords': _('Keywords'),
+ 'time': _('Preparation time in minutes'),
'file_path': _('Path'),
'file_uid': _('Storage UID'),
}
@@ -36,12 +37,13 @@ class ExternalRecipeForm(forms.ModelForm):
class InternalRecipeForm(forms.ModelForm):
class Meta:
model = Recipe
- fields = ('name', 'instructions', 'keywords')
+ fields = ('name', 'instructions', 'time', 'keywords')
labels = {
'name': _('Name'),
'keywords': _('Keywords'),
'instructions': _('Instructions'),
+ 'time': _('Preparation time in minutes'),
}
widgets = {'keywords': MultiSelectWidget}
@@ -49,7 +51,7 @@ class InternalRecipeForm(forms.ModelForm):
class CommentForm(forms.ModelForm):
class Meta:
model = Comment
- fields = ('text', )
+ fields = ('text',)
labels = {
'text': _('Add your comment: '),
diff --git a/cookbook/migrations/0011_recipe_time.py b/cookbook/migrations/0011_recipe_time.py
new file mode 100644
index 00000000..d777bdc6
--- /dev/null
+++ b/cookbook/migrations/0011_recipe_time.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.2.7 on 2019-11-15 13:50
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('cookbook', '0010_recipe_internal'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='recipe',
+ name='time',
+ field=models.IntegerField(blank=True, default=0),
+ preserve_default=False,
+ ),
+ ]
diff --git a/cookbook/models.py b/cookbook/models.py
index dc872194..c3347fbd 100644
--- a/cookbook/models.py
+++ b/cookbook/models.py
@@ -61,6 +61,7 @@ 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(blank=True)
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 09b7fa57..452599e0 100644
--- a/cookbook/templates/recipe_view.html
+++ b/cookbook/templates/recipe_view.html
@@ -25,6 +25,12 @@
{% endif %}
+ {% if recipe.time and recipe.time != 0 %}
+ {% trans 'Preparation time ca.' %} {{ recipe.time }} min
+
+
+ {% endif %}
+
{% if ingredients %}