From 72202a4630212265976375993b456661eb733b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Fri, 22 Sep 2017 19:03:43 +0200 Subject: [PATCH] Handle special publications differently --- mainsite/context_processors.py | 5 ++ .../0004_publication_in_year_view_anyway.py | 20 +++++++ mainsite/models.py | 5 ++ ..._view.html => publications_list_view.html} | 0 mainsite/templates/sidebar.html | 4 ++ mainsite/urls.py | 2 + mainsite/views.py | 53 ++++++++++++++----- 7 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 mainsite/migrations/0004_publication_in_year_view_anyway.py rename mainsite/templates/mainsite/{year_view.html => publications_list_view.html} (100%) diff --git a/mainsite/context_processors.py b/mainsite/context_processors.py index c1d7057..edeb5d6 100644 --- a/mainsite/context_processors.py +++ b/mainsite/context_processors.py @@ -6,6 +6,11 @@ from . import models def sidebar_years(req): avail_years = models.PublicationYear.objects.all() publi_years = [year for year in avail_years if len(year.publis()) > 0] + + num_special_publications = models.Publication.objects\ + .filter(is_special=True).count() + return { 'publication_years': publi_years, + 'has_special_publications': num_special_publications > 0, } diff --git a/mainsite/migrations/0004_publication_in_year_view_anyway.py b/mainsite/migrations/0004_publication_in_year_view_anyway.py new file mode 100644 index 0000000..e7bb78e --- /dev/null +++ b/mainsite/migrations/0004_publication_in_year_view_anyway.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.5 on 2017-09-22 17:01 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainsite', '0003_siteconfiguration'), + ] + + operations = [ + migrations.AddField( + model_name='publication', + name='in_year_view_anyway', + field=models.BooleanField(default=False, help_text="Si le numéro est spécial, l'afficher quand même dans la page de l'année correspondante.", verbose_name="Aussi dans l'année"), + ), + ] diff --git a/mainsite/models.py b/mainsite/models.py index ff1dd03..74d5bda 100644 --- a/mainsite/models.py +++ b/mainsite/models.py @@ -32,6 +32,11 @@ class Publication(models.Model): is_special = BooleanField('Numéro spécial', help_text='Numéro du BOcal non-numéroté', default=False) + in_year_view_anyway = BooleanField( + "Aussi dans l'année", + help_text=("Si le numéro est spécial, l'afficher quand même dans la " + "page de l'année correspondante."), + default=False) descr = CharField('Description (optionnelle)', max_length=512, blank=True) diff --git a/mainsite/templates/mainsite/year_view.html b/mainsite/templates/mainsite/publications_list_view.html similarity index 100% rename from mainsite/templates/mainsite/year_view.html rename to mainsite/templates/mainsite/publications_list_view.html diff --git a/mainsite/templates/sidebar.html b/mainsite/templates/sidebar.html index dc52cdd..de73f30 100644 --- a/mainsite/templates/sidebar.html +++ b/mainsite/templates/sidebar.html @@ -14,6 +14,10 @@