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/*"}),
|
widget=forms.ClearableFileInput(attrs={'capture': True, 'accept': "image/*"}),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
|
photo_instr = forms.ImageField(
|
||||||
|
label="Photo des instructions",
|
||||||
|
widget=forms.ClearableFileInput(attrs={'capture': True, 'accept': "image/*"}),
|
||||||
|
required=False
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Recette
|
model = Recette
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
|
@ -6,7 +6,7 @@ from .models import Recette
|
||||||
class SearchForm(forms.Form):
|
class SearchForm(forms.Form):
|
||||||
text = forms.CharField(
|
text = forms.CharField(
|
||||||
widget=forms.TextInput(attrs={'autofocus': True}),
|
widget=forms.TextInput(attrs={'autofocus': True}),
|
||||||
required=False
|
label="Texte", required=False
|
||||||
)
|
)
|
||||||
saison = forms.ChoiceField(choices=(('all', "Toutes"),) + Recette.SAISON_CHOICES)
|
saison = forms.ChoiceField(choices=(('all', "Toutes"),) + Recette.SAISON_CHOICES)
|
||||||
veget = forms.BooleanField(label="Végétarien", required=False)
|
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)
|
nom = models.CharField("Nom", max_length=200)
|
||||||
photo = models.ImageField("Photo", upload_to='photos', blank=True)
|
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)
|
nb_pers = models.IntegerField(default=4)
|
||||||
saison = ChoiceArrayField(
|
saison = ChoiceArrayField(
|
||||||
models.CharField(max_length=10, choices=SAISON_CHOICES, blank=True),
|
models.CharField(max_length=10, choices=SAISON_CHOICES, blank=True),
|
||||||
|
|
|
@ -16,8 +16,13 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if recette.photo_instr %}
|
||||||
|
<div class="photo"><img src="{{ recette.photo_instr.url }}">
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% if recette.photo %}
|
{% 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 %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue