Add separate photo for instructions
This commit is contained in:
parent
1f9d5f8291
commit
5843203702
|
@ -20,6 +20,12 @@ class RecetteForm(forms.ModelForm):
|
|||
widget=forms.ClearableFileInput(attrs={'capture': True, 'accept': "image/*"}),
|
||||
required=False
|
||||
)
|
||||
photo_instr = forms.ImageField(
|
||||
label="Photo des instructions",
|
||||
widget=forms.ClearableFileInput(attrs={'capture': True, 'accept': "image/*"}),
|
||||
required=False
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Recette
|
||||
fields = '__all__'
|
||||
|
|
|
@ -6,7 +6,7 @@ from .models import Recette
|
|||
class SearchForm(forms.Form):
|
||||
text = forms.CharField(
|
||||
widget=forms.TextInput(attrs={'autofocus': True}),
|
||||
required=False
|
||||
label="Texte", required=False
|
||||
)
|
||||
saison = forms.ChoiceField(choices=(('all', "Toutes"),) + Recette.SAISON_CHOICES)
|
||||
veget = forms.BooleanField(label="Végétarien", required=False)
|
||||
|
|
18
recette/migrations/0004_recette_photo_instr.py
Normal file
18
recette/migrations/0004_recette_photo_instr.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.0.5 on 2018-10-14 16:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('recette', '0003_recette_is_veget'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='recette',
|
||||
name='photo_instr',
|
||||
field=models.ImageField(blank=True, upload_to='photos', verbose_name='Photo des instructions'),
|
||||
),
|
||||
]
|
|
@ -32,6 +32,7 @@ class Recette(models.Model):
|
|||
)
|
||||
nom = models.CharField("Nom", max_length=200)
|
||||
photo = models.ImageField("Photo", upload_to='photos', blank=True)
|
||||
photo_instr = models.ImageField("Photo des instructions", upload_to='photos', blank=True)
|
||||
nb_pers = models.IntegerField(default=4)
|
||||
saison = ChoiceArrayField(
|
||||
models.CharField(max_length=10, choices=SAISON_CHOICES, blank=True),
|
||||
|
|
|
@ -16,8 +16,13 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if recette.photo_instr %}
|
||||
<div class="photo"><img src="{{ recette.photo_instr.url }}">
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if recette.photo %}
|
||||
<div class="photo"><img src="{{ recette.photo.url }}"></div>
|
||||
<div class="photo"{% if recette.ingredients.count or recette.photo_instr %} style="max-width: 50%"{% endif %}><img src="{{ recette.photo.url }}">
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
|
Loading…
Reference in a new issue