Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
e5e1b135
Unverified
Commit
e5e1b135
authored
Jan 25, 2017
by
Joost Rijneveld
Browse files
Gracefully try to correct board URLs with one year
parent
b28cb05d
Changes
3
Hide whitespace changes
Inline
Side-by-side
website/activemembers/models.py
View file @
e5e1b135
...
...
@@ -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
),
str
(
self
.
until
.
year
)])
def
validate_unique
(
self
,
*
args
,
**
kwargs
):
""" Check uniqueness"""
...
...
website/activemembers/urls.py
View file @
e5e1b135
...
...
@@ -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'
),
]
website/activemembers/views.py
View file @
e5e1b135
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment