Add dessert boolean field

This commit is contained in:
Claude Paroz 2019-02-16 12:33:57 +01:00
parent f9b567ec9d
commit 65a847f603
4 changed files with 21 additions and 1 deletions

View file

@ -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:

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

View file

@ -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)

View file

@ -1,3 +1,3 @@
django>=2.0
django>=2.1
pillow
easy-thumbnails==2.5