time
This commit is contained in:
parent
9bd5e737a9
commit
ce27ae88f1
@ -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: '),
|
||||
|
19
cookbook/migrations/0011_recipe_time.py
Normal file
19
cookbook/migrations/0011_recipe_time.py
Normal file
@ -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,
|
||||
),
|
||||
]
|
@ -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)
|
||||
|
@ -25,6 +25,12 @@
|
||||
<br/>
|
||||
{% endif %}
|
||||
|
||||
{% if recipe.time and recipe.time != 0 %}
|
||||
<small>{% trans 'Preparation time ca.' %} {{ recipe.time }} min </small>
|
||||
<br/>
|
||||
<br/>
|
||||
{% endif %}
|
||||
|
||||
{% if ingredients %}
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
|
@ -39,6 +39,7 @@ 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.save()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user