forked from DGNum/gestioCOF
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:
|
class Meta:
|
||||||
model = Article
|
model = Article
|
||||||
fields = ['name', 'is_sold', 'price', 'stock', 'category', 'box_type',
|
fields = ['name', 'is_sold', 'hidden', 'price', 'stock', 'category', 'box_type',
|
||||||
'box_capacity']
|
'box_capacity']
|
||||||
|
|
||||||
class ArticleRestrictForm(ArticleForm):
|
class ArticleRestrictForm(ArticleForm):
|
||||||
class Meta(ArticleForm.Meta):
|
class Meta(ArticleForm.Meta):
|
||||||
fields = ['name', 'is_sold', 'price', 'category', 'box_type',
|
fields = ['name', 'is_sold', 'hidden', 'price', 'category', 'box_type',
|
||||||
'box_capacity']
|
'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):
|
class Article(models.Model):
|
||||||
name = models.CharField(max_length = 45)
|
name = models.CharField(max_length = 45)
|
||||||
is_sold = models.BooleanField(default = True)
|
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(
|
price = models.DecimalField(
|
||||||
max_digits = 6, decimal_places = 2,
|
max_digits = 6, decimal_places = 2,
|
||||||
default = 0)
|
default = 0)
|
||||||
|
|
|
@ -48,12 +48,10 @@ class Home(TemplateView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(TemplateView, self).get_context_data(**kwargs)
|
context = super(TemplateView, self).get_context_data(**kwargs)
|
||||||
articles = Article.objects.all()
|
articles = Article.objects.all().filter(is_sold=True, hidden=False)
|
||||||
context['pressions'] = (articles.filter(category__name='Pression')
|
context['pressions'] = articles.filter(category__name='Pression')
|
||||||
.filter(is_sold=True))
|
|
||||||
context['articles'] = (articles.exclude(category__name='Pression')
|
context['articles'] = (articles.exclude(category__name='Pression')
|
||||||
.filter(is_sold=True)
|
.order_by('category'))
|
||||||
.order_by('category'))
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
|
|
Loading…
Reference in a new issue