Add dessert boolean field
This commit is contained in:
parent
f9b567ec9d
commit
65a847f603
|
@ -12,12 +12,15 @@ class SearchForm(forms.Form):
|
|||
)
|
||||
saison = forms.ChoiceField(choices=(('all', "Toutes"),) + Recette.SAISON_CHOICES)
|
||||
veget = forms.BooleanField(label="Végétarien", required=False)
|
||||
dessert = forms.BooleanField(label="Dessert", required=False)
|
||||
|
||||
def search(self):
|
||||
if self.is_valid():
|
||||
qs = Recette.objects.all()
|
||||
if self.cleaned_data['veget']:
|
||||
qs = qs.filter(is_veget=True)
|
||||
if self.cleaned_data['dessert']:
|
||||
qs = qs.filter(is_dessert=True)
|
||||
if self.cleaned_data['text']:
|
||||
terms = [t for t in self.cleaned_data['text'].split() if t not in STOP_WORDS]
|
||||
for term in terms:
|
||||
|
|
16
recette/migrations/0006_recette_is_dessert.py
Normal file
16
recette/migrations/0006_recette_is_dessert.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('recette', '0005_postgres_unaccent'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='recette',
|
||||
name='is_dessert',
|
||||
field=models.BooleanField(default=False, verbose_name='Dessert'),
|
||||
),
|
||||
]
|
|
@ -39,6 +39,7 @@ class Recette(models.Model):
|
|||
verbose_name="Saison",
|
||||
)
|
||||
is_veget = models.BooleanField("Mets végétarien", default=False)
|
||||
is_dessert = models.BooleanField("Dessert", default=False)
|
||||
prep = models.TextField("Préparation", blank=True)
|
||||
source = models.CharField("Source", max_length=200, blank=True)
|
||||
ingredients = models.ManyToManyField(Ingredient, through='Composition', blank=True)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
django>=2.0
|
||||
django>=2.1
|
||||
pillow
|
||||
easy-thumbnails==2.5
|
||||
|
|
Loading…
Reference in a new issue