Add description text and page header to publi views

This commit is contained in:
Théophile Bastian 2017-09-23 19:07:13 +02:00
parent 3fbd7b5859
commit 5fccab444e
5 changed files with 56 additions and 4 deletions

View file

@ -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,
),
]

View file

@ -15,6 +15,8 @@ class SiteConfiguration(SingletonModel):
email = CharField("Adresse de contact du BOcal", email = CharField("Adresse de contact du BOcal",
max_length=128, max_length=128,
help_text="Attention au spam…") help_text="Attention au spam…")
specialPublisDescr = MarkdownxField("Texte de la page des "
"publications spéciales (Markdown)")
def __str__(self): def __str__(self):
return "Configuration du site" return "Configuration du site"

View file

@ -112,3 +112,12 @@ body {
.main .page-header { .main .page-header {
margin-top: 0; margin-top: 0;
} }
.page-title {
text-align: center;
margin-bottom: 20px;
}
.intro-text {
margin-bottom: 20px;
}

View file

@ -3,10 +3,18 @@
{% block content %} {% block content %}
<p class="intro_text">{{ intro_text | markdownify }}</p> <h2 class="page-title">
{% if is_year_view %}
Millésime {{ year_range }}
{% else %}
{{ list_title }}
{% endif %}
</h2>
<div class="intro-text">{{ intro_text | markdownify }}</div>
{% for bocal in publications %}
<ul class="publication-list"> <ul class="publication-list">
{% for bocal in publications %}
<li class="publication-entry"> <li class="publication-entry">
<a href="{{ bocal.url }}" title="Lire le BOcal !">{{ bocal }}</a>&nbsp;: <a href="{{ bocal.url }}" title="Lire le BOcal !">{{ bocal }}</a>&nbsp;:
@ -17,6 +25,6 @@
<span class="publication-date">{{ bocal.date | date:"d/m/Y" }}</span> <span class="publication-date">{{ bocal.date | date:"d/m/Y" }}</span>
{% endif %} {% endif %}
</li> </li>
</ul>
{% endfor %} {% endfor %}
</ul>
{% endblock content %} {% endblock content %}

View file

@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404
from django.views.generic import TemplateView from django.views.generic import TemplateView
from django.http import Http404 from django.http import Http404
from mainsite.models import Publication, PublicationYear from mainsite.models import Publication, PublicationYear, SiteConfiguration
class HomeView(TemplateView): class HomeView(TemplateView):
@ -59,6 +59,8 @@ class YearView(PublicationListView):
def additional_context(self, year, nYear): def additional_context(self, year, nYear):
return { return {
'intro_text': self.pubYear.descr, 'intro_text': self.pubYear.descr,
'is_year_view': True,
'year_range': self.pubYear.prettyName,
} }
def get_publications(self, year, nYear): def get_publications(self, year, nYear):
@ -67,6 +69,15 @@ class YearView(PublicationListView):
class SpecialPublicationsView(PublicationListView): class SpecialPublicationsView(PublicationListView):
''' Display the list of special publications ''' ''' 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): def get_publications(self):
publications = Publication.objects\ publications = Publication.objects\
.filter(is_special=True)\ .filter(is_special=True)\