We planned to upgrade GitLab and Mattermost to the latest version this Friday morning (early). You may experience some downtime!

Commit 3f0c6fd8 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Add legacy redirect for newsletters

parent add7c976
......@@ -7,4 +7,6 @@ app_name = "newsletters"
urlpatterns = [
url('^(?P<pk>\d+)/$', views.preview, name='preview'),
url(r'admin/send/(?P<pk>\d+)/$', views.admin_send, name='admin-send'),
views.legacy_redirect, name='legacy-redirect')
......@@ -7,6 +7,8 @@ from django.template import Context
from django.template.loader import get_template
from django.utils import translation
from datetime import datetime, timedelta, date
from members.models import Member
from newsletters.models import Newsletter
from partners.models import Partner
......@@ -24,6 +26,17 @@ def preview(request, pk):
def legacy_redirect(request, year, week):
newsletter_date = datetime.strptime(
'%s-%s-1' % (year, week), '%Y-%W-%w')
if date(int(year), 1, 4).isoweekday() > 4:
newsletter_date -= timedelta(days=7)
newsletter = get_object_or_404(Newsletter, date=newsletter_date)
return redirect(newsletter.get_absolute_url(), permanent=True)
def admin_send(request, pk):
......@@ -57,6 +57,7 @@ urlpatterns = [
url(r'^pizzas/', include('pizzas.urls')),
url(r'^index\.php/events/ical/feed\.ics', DeprecationFeed()),
url(r'^newsletters/', include('newsletters.urls')),
url(r'^nieuwsbrief/', include('newsletters.urls')), # for legacy reasons
url(r'^association$', TemplateView.as_view(
template_name='singlepages/association.html'), name='association'),
url(r'^', include([ # 'association' menu
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