Unverified Commit e5e1b135 authored by Joost Rijneveld's avatar Joost Rijneveld
Browse files

Gracefully try to correct board URLs with one year

parent b28cb05d
......@@ -136,8 +136,8 @@ class Board(Committee):
ordering = ['-since']
def get_absolute_url(self):
return reverse('activemembers:board',
args=['{}-{}'.format(self.since.year, self.until.year)])
return reverse('activemembers:board', args=[str(self.since.year),
def validate_unique(self, *args, **kwargs):
""" Check uniqueness"""
......@@ -13,6 +13,7 @@ urlpatterns = [
url(r'committees/$', views.committee_index, name='committees'),
url(r'^committees/(?P<id>\d+)/$', views.committee_detail, name='committee'),
url(r'^boards/$', views.board_index, name='boards'),
url(r'^board/(?P<year>\d{4}-\d{4})$', views.board_detail, name='board'),
url(r'^board/(?P<since>\d{4})$', views.board_detail, name='board'),
url(r'^board/(?P<since>\d{4})-(?P<until>\d{4})$', views.board_detail, name='board'),
url(r'^board$', views.current_board, name='current-board'),
......@@ -44,9 +44,12 @@ def board_index(request):
{'boards': boards})
def board_detail(request, year):
def board_detail(request, since, until=None):
"""View the details of a board"""
since, until = year.split('-')
if not until: # try to correct /board/2016 to /2016-2017
return redirect(reverse('activemembers:board',
kwargs={'since': since,
'until': int(since) + 1}))
board = get_object_or_404(Board, since__year=since, until__year=until)
members = []
memberships = (CommitteeMembership
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