Commit 2dd74ecf authored by fred's avatar fred

add month archives for agenda

parent 47ff4732
......@@ -22,6 +22,8 @@ urlpatterns = patterns('',
url(r'^sons/archives/$', 'panikweb.search.listenArchives', name='listenArchives'),
url(r'^actus/$', 'panikweb.views.news', name='news'),
url(r'^actus/agenda/$', 'panikweb.views.agenda', name='agenda'),
url(r'^actus/agenda/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/$',
'panikweb.views.agenda_by_month', name='agenda_by_month'),
url(r'^actus/agenda$', RedirectView.as_view(pattern_name='agenda')),
url(r'^actus/archives/$', 'panikweb.search.newsArchives', name='newsArchives'),
url(r'^actus/(?P<slug>[\w,-]+)$', 'panikweb.views.newsitemview', name='newsitem-view'),
......
......@@ -13,6 +13,7 @@ from django.views.generic.base import TemplateView
from django.views.generic.detail import DetailView
from django.views.decorators.csrf import csrf_exempt
from django.views.generic.dates import _date_from_string
from django.views.generic.dates import MonthArchiveView
from django.core.paginator import Paginator
......@@ -476,11 +477,29 @@ class Agenda(TemplateView):
context['agenda'] = NewsItem.objects.filter(
event_date__gte=date.today()).order_by('date')[:20]
context['news'] = NewsItem.objects.all().order_by('-date')
context['previous_month'] = datetime.today().replace(day=1) - timedelta(days=2)
return context
agenda = Agenda.as_view()
class AgendaByMonth(MonthArchiveView):
template_name = 'agenda.html'
queryset = NewsItem.objects.filter(event_date__isnull=False)
allow_future = True
date_field = 'event_date'
month_format = '%m'
def get_context_data(self, **kwargs):
context = super(AgendaByMonth, self).get_context_data(**kwargs)
context['sectionName'] = "News"
context['agenda'] = context['object_list']
context['news'] = NewsItem.objects.all().order_by('-date')
return context
agenda_by_month = AgendaByMonth.as_view()
class Emissions(TemplateView):
template_name = 'emissions.html'
......
......@@ -1559,3 +1559,7 @@ div.episode-detail div.sound div.download-links {
div.extra-soundfiles div.download-links {
background: white;
}
div.previous-and-next-months {
margin-top: 1em;
}
......@@ -11,10 +11,14 @@
<div class="detail marged news cf">
<div class="wrapper navigation">
{% if month %}
<h2>{{month|date:"E Y"}}</h2>
{% else %}
<p class="intro leftPart">
Tous les jours, il s'en passe des choses que Panik fomente, fait résonner et
vous fait savoir.
</p>
{% endif %}
<div class="leftPart">
<div class="news">
......@@ -28,6 +32,21 @@ vous fait savoir.
{% if not agenda %}
<div class="big error center">Misère, c'est l'hiver ?!</div>
{% endif %}
<div class="previous-and-next-months">
<h4>
{% if previous_month %}
<a href="{% url 'agenda_by_month' year=previous_month.year month=previous_month.month %}"
>&lt; {{previous_month|date:'E Y'}}</a>
{% endif %}
{% if previous_month and next_month %}—{% endif %}
{% if next_month %}
<a href="{% url 'agenda_by_month' year=next_month.year month=next_month.month %}"
>{{next_month|date:'E Y'}} &gt;</a>
{% endif %}
</h4>
</div>
</div>
</div>
<div class="rightPart">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment