From 5fccab444eec791ce9228ec06143e8b1f3d1e8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sat, 23 Sep 2017 19:07:13 +0200 Subject: [PATCH] Add description text and page header to publi views --- ...07_siteconfiguration_specialpublisdescr.py | 22 +++++++++++++++++++ mainsite/models.py | 2 ++ mainsite/static/css/site-base.css | 9 ++++++++ .../mainsite/publications_list_view.html | 14 +++++++++--- mainsite/views.py | 13 ++++++++++- 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 mainsite/migrations/0007_siteconfiguration_specialpublisdescr.py diff --git a/mainsite/migrations/0007_siteconfiguration_specialpublisdescr.py b/mainsite/migrations/0007_siteconfiguration_specialpublisdescr.py new file mode 100644 index 0000000..4944d88 --- /dev/null +++ b/mainsite/migrations/0007_siteconfiguration_specialpublisdescr.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.5 on 2017-09-23 16:54 +from __future__ import unicode_literals + +from django.db import migrations +import markdownx.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainsite', '0006_auto_20170923_1847'), + ] + + operations = [ + migrations.AddField( + model_name='siteconfiguration', + name='specialPublisDescr', + field=markdownx.models.MarkdownxField(default='', verbose_name='Texte de la page des publications spéciales (Markdown)'), + preserve_default=False, + ), + ] diff --git a/mainsite/models.py b/mainsite/models.py index c1bb545..fd9fb05 100644 --- a/mainsite/models.py +++ b/mainsite/models.py @@ -15,6 +15,8 @@ class SiteConfiguration(SingletonModel): email = CharField("Adresse de contact du BOcal", max_length=128, help_text="Attention au spam…") + specialPublisDescr = MarkdownxField("Texte de la page des " + "publications spéciales (Markdown)") def __str__(self): return "Configuration du site" diff --git a/mainsite/static/css/site-base.css b/mainsite/static/css/site-base.css index 5a03c6c..0b57d81 100644 --- a/mainsite/static/css/site-base.css +++ b/mainsite/static/css/site-base.css @@ -112,3 +112,12 @@ body { .main .page-header { margin-top: 0; } + +.page-title { + text-align: center; + margin-bottom: 20px; +} + +.intro-text { + margin-bottom: 20px; +} diff --git a/mainsite/templates/mainsite/publications_list_view.html b/mainsite/templates/mainsite/publications_list_view.html index 956fe88..2977bb7 100644 --- a/mainsite/templates/mainsite/publications_list_view.html +++ b/mainsite/templates/mainsite/publications_list_view.html @@ -3,10 +3,18 @@ {% block content %} -

{{ intro_text | markdownify }}

+

+{% if is_year_view %} +Millésime {{ year_range }} +{% else %} +{{ list_title }} +{% endif %} +

+ +
{{ intro_text | markdownify }}
-{% for bocal in publications %} {% endfor %} + {% endblock content %} diff --git a/mainsite/views.py b/mainsite/views.py index d9f9189..090b559 100644 --- a/mainsite/views.py +++ b/mainsite/views.py @@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404 from django.views.generic import TemplateView from django.http import Http404 -from mainsite.models import Publication, PublicationYear +from mainsite.models import Publication, PublicationYear, SiteConfiguration class HomeView(TemplateView): @@ -59,6 +59,8 @@ class YearView(PublicationListView): def additional_context(self, year, nYear): return { 'intro_text': self.pubYear.descr, + 'is_year_view': True, + 'year_range': self.pubYear.prettyName, } def get_publications(self, year, nYear): @@ -67,6 +69,15 @@ class YearView(PublicationListView): class SpecialPublicationsView(PublicationListView): ''' Display the list of special publications ''' + + def additional_context(self): + siteConf = SiteConfiguration.get_solo() + return { + 'intro_text': siteConf.specialPublisDescr, + 'is_year_view': False, + 'list_title': "Numéros spéciaux", + } + def get_publications(self): publications = Publication.objects\ .filter(is_special=True)\