Commit 1d7d95c7 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Merge branch 'fix_registrationinformationfield_ordering' into 'master'

Fix RegistrationInformationfield ordering

Closes #592

See merge request !732
parents c9a53c76 162db37d
......@@ -7,9 +7,9 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-12 14:06+0100\n"
"PO-Revision-Date: 2018-02-14 17:07+0100\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"POT-Creation-Date: 2018-02-16 08:57+0100\n"
"PO-Revision-Date: 2018-02-16 08:57+0100\n"
"Last-Translator: Thom Wiggers <thom@thomwiggers.nl>\n"
"Language-Team: \n"
"Language: nl\n"
"MIME-Version: 1.0\n"
......@@ -18,27 +18,27 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.0.6\n"
#: admin.py:90
#: admin.py:95
msgid "Event Date"
msgstr "Evenementdatum"
#: admin.py:99
#: admin.py:104
msgid "Registration Start"
msgstr "Start Aanmelden"
#: admin.py:102
#: admin.py:107
msgid "Edit"
msgstr "Aanpassen"
#: admin.py:112
#: admin.py:117
msgid "Number of participants"
msgstr "Aantal deelnemers"
#: admin.py:116
#: admin.py:121
msgid "Publish selected events"
msgstr "Publiceer geselecteerde evenementen"
#: admin.py:120
#: admin.py:125
msgid "Unpublish selected events"
msgstr "Publicatie van geselecteerde evenementen ongedaan maken"
......@@ -367,24 +367,28 @@ msgstr "verplicht"
msgid "last changed"
msgstr "laatst aangepast"
#: services.py:82
#: services.py:81
msgid ""
"You cannot re-register anymore since you've cancelled after the deadline."
msgstr ""
"Je kunt je niet opnieuw aanmelden omdat je je hebt afgemeld na de deadline."
#: services.py:92
#: services.py:91
msgid "You were already registered."
msgstr "Je bent al aangemeld."
#: services.py:94
#: services.py:93
msgid "You may not register."
msgstr "Je mag je niet aanmelden."
#: services.py:123 services.py:137 services.py:189
#: services.py:122 services.py:136 services.py:167
msgid "You are not registered for this event."
msgstr "Je bent niet aangemeld voor dit evenement."
#: services.py:190
msgid "You are not allowed to update this registration."
msgstr "Je mag deze aanmelding niet bijwerken."
#: templates/events/admin/details.html:4 templates/events/admin/details.html:5
#: templates/events/admin/email_export.html:4
#: templates/events/admin/email_export.html:5
......
from collections import OrderedDict
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _, get_language
......@@ -160,13 +162,14 @@ def registration_fields(member, event):
event=event,
member=member
)
except Registration.DoesNotExist:
pass
except Registration.DoesNotExist as error:
raise RegistrationError(
_("You are not registered for this event.")) from error
if (event_permissions(member, event)["update_registration"] and
registration):
information_fields = registration.information_fields
fields = {}
fields = OrderedDict()
for information_field in information_fields:
field = information_field["field"]
......@@ -183,4 +186,5 @@ def registration_fields(member, event):
return fields
else:
raise RegistrationError(_("You are not registered for this event."))
raise RegistrationError(
_("You are not allowed to update this registration."))
......@@ -364,6 +364,8 @@ class ServicesTest(TestCase):
RegistrationInformationField.objects.create(
id=1,
name_en='1',
name_nl='1',
type=RegistrationInformationField.INTEGER_FIELD,
event=self.event,
required=False,
......@@ -371,6 +373,8 @@ class ServicesTest(TestCase):
RegistrationInformationField.objects.create(
id=2,
name_en='2',
name_nl='2',
type=RegistrationInformationField.BOOLEAN_FIELD,
event=self.event,
required=True,
......@@ -378,16 +382,20 @@ class ServicesTest(TestCase):
RegistrationInformationField.objects.create(
id=3,
name_nl='3',
name_en='3',
type=RegistrationInformationField.TEXT_FIELD,
event=self.event,
required=False,
)
# set order
self.event.set_registrationinformationfield_order([1, 2, 3])
fields = services.registration_fields(self.member, self.event)
self.assertEqual(fields['info_field_1'], {
'type': 'integer',
'label': '',
'label': '1',
'description': None,
'value': None,
'required': False
......@@ -395,7 +403,7 @@ class ServicesTest(TestCase):
self.assertEqual(fields['info_field_2'], {
'type': 'boolean',
'label': '',
'label': '2',
'description': None,
'value': None,
'required': True
......@@ -403,10 +411,13 @@ class ServicesTest(TestCase):
self.assertEqual(fields['info_field_3'], {
'type': 'text',
'label': '',
'label': '3',
'description': None,
'value': None,
'required': False
})
self.assertEqual(len(fields), 3)
# Test that the ordering is correct
labels = [field['label'] for field in fields.values()]
self.assertEqual(labels, sorted(labels))
Supports Markdown
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