Commit 6586db3d authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'refactor/beautify-board-urls' into 'master'

Improve board urls

See merge request !325
parents 168f03cf c90dcd33
......@@ -26,5 +26,24 @@
"photo": "Thom_Wiggers_4YRoxV3.jpg",
"permissions": []
}
},
{
"model": "activemembers.committee",
"pk": 3,
"fields": {
"name_nl": "testbestuur1",
"name_en": "testboard1",
"description_nl": "testdesc1",
"description_en": "testdesc1",
"since": "1990-09-01",
"until": "1991-09-01"
}
},
{
"model": "activemembers.board",
"pk": 3,
"fields": {
"is_board": true
}
}
]
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-14 16:30+0100\n"
"PO-Revision-Date: 2017-01-14 16:31+0100\n"
"POT-Creation-Date: 2017-01-24 21:36+0100\n"
"PO-Revision-Date: 2017-01-24 21:36+0100\n"
"Last-Translator: Joost Rijneveld <joost@joostrijneveld.nl>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -18,117 +18,121 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.11\n"
#: models.py:43
#: models.py:53
msgid "Committee name"
msgstr "Commissienaam"
#: models.py:49
#: models.py:59
msgid "Description"
msgstr "Beschrijving"
#: models.py:53
#: models.py:63
msgid "Image"
msgstr "Afbeelding"
#: models.py:66
#: models.py:76
msgid "permissions"
msgstr "permissies"
#: models.py:71
#: models.py:81
msgid "founded in"
msgstr "opgericht in"
#: models.py:77
#: models.py:87
msgid "existed until"
msgstr "bestond tot"
#: models.py:84
#: models.py:94
msgid "contact email address"
msgstr "contact e-mailadres"
#: models.py:87
#: models.py:97
msgid "Wiki namespace"
msgstr "Wiki namespace"
#: models.py:99
#: models.py:109
msgid "committee"
msgstr "commissie"
#: models.py:100 templates/activemembers/committee_index.html:6
#: models.py:110 templates/activemembers/committee_index.html:6
msgid "committees"
msgstr "commissies"
#: models.py:117
#: models.py:131
msgid "Is this a board"
msgstr "Is dit een bestuur"
#: models.py:142 models.py:257
#: models.py:149 models.py:150
msgid "A board already exists for those years"
msgstr "Er bestaat al een bestuur voor die jaren"
#: models.py:167 models.py:296
msgid "Member"
msgstr "Lid"
#: models.py:148
#: models.py:173
msgid "Committee"
msgstr "Commissie"
#: models.py:152
#: models.py:177
msgid "Committee member since"
msgstr "Commissielid sinds"
#: models.py:153
#: models.py:178
msgid "The date this member joined the committee in this role"
msgstr "De datum waarop deze persoon lid werd deze commissie in deze rol"
#: models.py:158
#: models.py:183
msgid "Committee member until"
msgstr "Commissielid tot"
#: models.py:159
#: models.py:184
msgid "A member of this committee until this time (can't be in the future)."
msgstr ""
"De datum waarop deze persoon de commissie verliet (kan niet in de toekomst "
"liggen)"
#: models.py:166
#: models.py:191
msgid "Chair of the committee"
msgstr "Voorzitter van de commissie"
#: models.py:167
#: models.py:192
msgid "There can only be one chair at a time!"
msgstr "Er kan maar één voorzitter tegelijkertijd zijn!"
#: models.py:173
#: models.py:198
msgid "role"
msgstr "rol"
#: models.py:174
#: models.py:199
msgid "The role of this member"
msgstr "De rol van dit lid binnen de commissie"
#: models.py:189
#: models.py:225
msgid "End date can't be before start date"
msgstr "De einddatum kan niet voor de startdatum liggen"
#: models.py:192
#: models.py:229
msgid "End date cannot be set for boards"
msgstr "Voor besturen kan geen einddatum worden opgegeven"
#: models.py:213
#: models.py:252
msgid "There already is a chair for this time period"
msgstr "Er is al een voorzitter voor deze periode"
#: models.py:229
#: models.py:268
msgid "This member is already in the committee for this period"
msgstr "Deze persoon is al lid van deze commissie in de aangegeven periode"
#: models.py:249
#: models.py:288
msgid "committee membership"
msgstr "commissielidmaatschap"
#: models.py:250
#: models.py:289
msgid "committee memberships"
msgstr "commissielidmaatschappen"
#: models.py:262
#: models.py:301
#, python-brace-format
msgid "{name} mentor in {year}"
msgstr "{name} mentor in {year}"
......
......@@ -136,7 +136,18 @@ class Board(Committee):
ordering = ['-since']
def get_absolute_url(self):
return reverse('activemembers:board', args=[str(self.pk)])
return reverse('activemembers:board', args=[str(self.since.year),
str(self.until.year)])
def validate_unique(self, *args, **kwargs):
""" Check uniqueness"""
super().validate_unique(*args, **kwargs)
for board in Board.objects.filter(since__year=self.since.year,
until__year=self.until.year):
if board is not self:
raise ValidationError({
'since': _('A board already exists for those years'),
'until': _('A board already exists for those years')})
class ActiveMembershipManager(models.Manager):
......
......@@ -4,7 +4,7 @@ from django.db.utils import IntegrityError
from django.test import TestCase
from django.utils import timezone
from activemembers.models import Committee, CommitteeMembership
from activemembers.models import Committee, CommitteeMembership, Board
from members.models import Member
......@@ -144,3 +144,13 @@ class PermissionsBackendTest(TestCase):
def test_nonmember_user(self):
u = get_user_model().objects.create(username='foo')
self.assertEqual(set(), u.get_all_permissions())
class BoardTest(TestCase):
fixtures = ['committees.json']
def setUp(self):
self.testboard = Board.objects.get(pk=3)
def test_get_absolute_url(self):
self.testboard.get_absolute_url()
......@@ -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'^boards/(?P<id>\d+)?$', 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,13 @@ def board_index(request):
{'boards': boards})
def board_detail(request, id):
def board_detail(request, since, until=None):
"""View the details of a board"""
board = get_object_or_404(Board, pk=id)
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
.objects
......
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