diff --git a/kfet/static/kfet/css/home.css b/kfet/static/kfet/css/home.css index cf584eac..eedb9048 100644 --- a/kfet/static/kfet/css/home.css +++ b/kfet/static/kfet/css/home.css @@ -41,3 +41,10 @@ li.carte-line { padding-left: 4px; position: relative; } + + +.unbreakable.carte-inverted .carte-ukf, +.unbreakable.carte-inverted .carte-label, +.unbreakable.carte-inverted { + background: #FFDBC7; +} diff --git a/kfet/templates/kfet/home.html b/kfet/templates/kfet/home.html index d427fe9c..31feece2 100644 --- a/kfet/templates/kfet/home.html +++ b/kfet/templates/kfet/home.html @@ -28,35 +28,37 @@

Carte

-
+

Pressions du moment

    - {% for article in pressions.articles.all %} - {% if article.is_sold %} + {% for article in pressions %}
  • {{ article.name }} {{ article.price | ukf:False}} UKF
  • - {% endif %} {% endfor %}
- {% for category in categories %} -
-

{{ category.name }}

-
    - {% for article in category.articles.all %} - {% if article.is_sold %} -
  • -
    - {{ article.name }} - {{ article.price | ukf:False}} UKF -
  • + {% for article in articles %} + {% ifchanged article.category %} + {% if not forloop.first %} +
+
+ {% endif %} +
+

{{ article.category.name }}

+
    + {% endifchanged %} +
  • +
    + {{ article.name }} + {{ article.price | ukf:False}} UKF +
  • + {% if foorloop.last %} +
+
{% endif %} - {% endfor %} - -
{% endfor %}
diff --git a/kfet/views.py b/kfet/views.py index 9c124fa3..869d2376 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -48,9 +48,12 @@ class Home(TemplateView): def get_context_data(self, **kwargs): context = super(TemplateView, self).get_context_data(**kwargs) - categories = ArticleCategory.objects.all() - context['pressions'] = categories.get(name='Pression') - context['categories'] = categories.exclude(name='Pression') + articles = Article.objects.all() + context['pressions'] = (articles.filter(category__name='Pression') + .filter(is_sold=True)) + context['articles'] = (articles.exclude(category__name='Pression') + .filter(is_sold=True) + .order_by('category')) return context @method_decorator(login_required)