This commit is contained in:
vabene1111 2019-11-15 15:00:25 +01:00
parent 9bd5e737a9
commit ce27ae88f1
5 changed files with 32 additions and 3 deletions

View File

@ -22,11 +22,12 @@ class ExternalRecipeForm(forms.ModelForm):
class Meta: class Meta:
model = Recipe model = Recipe
fields = ('name', 'keywords', 'file_path', 'storage', 'file_uid') fields = ('name', 'keywords', 'time', 'file_path', 'storage', 'file_uid')
labels = { labels = {
'name': _('Name'), 'name': _('Name'),
'keywords': _('Keywords'), 'keywords': _('Keywords'),
'time': _('Preparation time in minutes'),
'file_path': _('Path'), 'file_path': _('Path'),
'file_uid': _('Storage UID'), 'file_uid': _('Storage UID'),
} }
@ -36,12 +37,13 @@ class ExternalRecipeForm(forms.ModelForm):
class InternalRecipeForm(forms.ModelForm): class InternalRecipeForm(forms.ModelForm):
class Meta: class Meta:
model = Recipe model = Recipe
fields = ('name', 'instructions', 'keywords') fields = ('name', 'instructions', 'time', 'keywords')
labels = { labels = {
'name': _('Name'), 'name': _('Name'),
'keywords': _('Keywords'), 'keywords': _('Keywords'),
'instructions': _('Instructions'), 'instructions': _('Instructions'),
'time': _('Preparation time in minutes'),
} }
widgets = {'keywords': MultiSelectWidget} widgets = {'keywords': MultiSelectWidget}
@ -49,7 +51,7 @@ class InternalRecipeForm(forms.ModelForm):
class CommentForm(forms.ModelForm): class CommentForm(forms.ModelForm):
class Meta: class Meta:
model = Comment model = Comment
fields = ('text', ) fields = ('text',)
labels = { labels = {
'text': _('Add your comment: '), 'text': _('Add your comment: '),

View 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,
),
]

View File

@ -61,6 +61,7 @@ class Recipe(models.Model):
file_path = models.CharField(max_length=512, default="") file_path = models.CharField(max_length=512, default="")
link = models.CharField(max_length=512, default="") link = models.CharField(max_length=512, default="")
keywords = models.ManyToManyField(Keyword, blank=True) keywords = models.ManyToManyField(Keyword, blank=True)
time = models.IntegerField(blank=True)
internal = models.BooleanField(default=False) internal = models.BooleanField(default=False)
created_by = models.ForeignKey(User, on_delete=models.PROTECT) created_by = models.ForeignKey(User, on_delete=models.PROTECT)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)

View File

@ -25,6 +25,12 @@
<br/> <br/>
{% endif %} {% endif %}
{% if recipe.time and recipe.time != 0 %}
<small>{% trans 'Preparation time ca.' %} {{ recipe.time }} min </small>
<br/>
<br/>
{% endif %}
{% if ingredients %} {% if ingredients %}
<div class="card" style="width: 18rem;"> <div class="card" style="width: 18rem;">
<div class="card-body"> <div class="card-body">

View File

@ -39,6 +39,7 @@ def internal_recipe_update(request, pk):
recipe = recipe_instance recipe = recipe_instance
recipe.name = form.cleaned_data['name'] recipe.name = form.cleaned_data['name']
recipe.instructions = form.cleaned_data['instructions'] recipe.instructions = form.cleaned_data['instructions']
recipe.time = form.cleaned_data['time']
recipe.save() recipe.save()