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'),
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
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'
div.extra-soundfiles div.download-links {
background: white;
}
+
+div.previous-and-next-months {
+ margin-top: 1em;
+}
<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">
{% 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 %}"
+ >< {{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'}} ></a>
+ {% endif %}
+</h4>
+ </div>
+
</div>
</div>
<div class="rightPart">