adding argumement hidden
to Article
in order to avoid some articles to appear in the menu
This commit is contained in:
parent
3ca38bd8e9
commit
aa1afccf1f
4 changed files with 28 additions and 7 deletions
|
@ -262,12 +262,12 @@ class ArticleForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = Article
|
||||
fields = ['name', 'is_sold', 'price', 'stock', 'category', 'box_type',
|
||||
fields = ['name', 'is_sold', 'hidden', 'price', 'stock', 'category', 'box_type',
|
||||
'box_capacity']
|
||||
|
||||
class ArticleRestrictForm(ArticleForm):
|
||||
class Meta(ArticleForm.Meta):
|
||||
fields = ['name', 'is_sold', 'price', 'category', 'box_type',
|
||||
fields = ['name', 'is_sold', 'hidden', 'price', 'category', 'box_type',
|
||||
'box_capacity']
|
||||
|
||||
# -----
|
||||
|
|
19
kfet/migrations/0048_article_hidden.py
Normal file
19
kfet/migrations/0048_article_hidden.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('kfet', '0047_auto_20170104_1528'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='article',
|
||||
name='hidden',
|
||||
field=models.BooleanField(help_text='Si oui, ne sera pas affiché au public ; par exemple sur la carte.', default=False),
|
||||
),
|
||||
]
|
|
@ -331,6 +331,10 @@ class ArticleCategory(models.Model):
|
|||
class Article(models.Model):
|
||||
name = models.CharField(max_length = 45)
|
||||
is_sold = models.BooleanField(default = True)
|
||||
hidden = models.BooleanField(default=False,
|
||||
help_text="Si oui, ne sera pas affiché "
|
||||
"au public ; par exemple "
|
||||
"sur la carte.")
|
||||
price = models.DecimalField(
|
||||
max_digits = 6, decimal_places = 2,
|
||||
default = 0)
|
||||
|
|
|
@ -48,12 +48,10 @@ class Home(TemplateView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(TemplateView, self).get_context_data(**kwargs)
|
||||
articles = Article.objects.all()
|
||||
context['pressions'] = (articles.filter(category__name='Pression')
|
||||
.filter(is_sold=True))
|
||||
articles = Article.objects.all().filter(is_sold=True, hidden=False)
|
||||
context['pressions'] = articles.filter(category__name='Pression')
|
||||
context['articles'] = (articles.exclude(category__name='Pression')
|
||||
.filter(is_sold=True)
|
||||
.order_by('category'))
|
||||
.order_by('category'))
|
||||
return context
|
||||
|
||||
@method_decorator(login_required)
|
||||
|
|
Loading…
Reference in a new issue