Skip to content
GitLab
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
1ec044fd
Verified
Commit
1ec044fd
authored
Sep 20, 2018
by
Sébastiaan Versteeg
Browse files
Make student number required for member registrations
parent
3da5d0b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
website/registrations/forms.py
View file @
1ec044fd
...
...
@@ -11,6 +11,7 @@ from .models import Registration, Renewal
class
MemberRegistrationForm
(
forms
.
ModelForm
):
"""Form for membership registrations"""
birthday
=
forms
.
DateField
(
widget
=
forms
.
widgets
.
SelectDateWidget
(
years
=
[
year
for
year
in
range
(
timezone
.
now
().
year
-
50
,
...
...
website/registrations/models.py
View file @
1ec044fd
...
...
@@ -264,6 +264,10 @@ class Registration(Entry):
_
(
'A user with that student number already exists. '
'Login using the existing account and renew the '
'membership by visiting the account settings.'
)})
elif
(
self
.
student_number
is
None
and
self
.
membership_type
!=
Membership
.
SUPPORTER
):
errors
.
update
({
'student_number'
:
_
(
'This field is required.'
)})
if
self
.
username
is
not
None
and
get_user_model
().
objects
.
filter
(
username
=
self
.
username
).
exists
():
...
...
website/registrations/tests/test_forms.py
View file @
1ec044fd
...
...
@@ -28,7 +28,7 @@ class MemberRegistrationFormTest(TestCase):
'privacy_policy'
:
1
,
}
def
test_
is_vali
d
(
self
):
def
test_
privacy_policy_checke
d
(
self
):
with
self
.
subTest
(
"Form is valid"
):
form
=
forms
.
MemberRegistrationForm
(
self
.
data
)
self
.
assertTrue
(
form
.
is_valid
(),
msg
=
dict
(
form
.
errors
))
...
...
website/registrations/tests/test_models.py
View file @
1ec044fd
...
...
@@ -75,6 +75,7 @@ class RegistrationTest(TestCase):
address_postal_code
=
'6525AJ'
,
address_city
=
'Nijmegen'
,
phone_number
=
'06123456789'
,
student_number
=
's1234567'
,
birthday
=
timezone
.
now
().
replace
(
year
=
1990
),
language
=
'en'
,
length
=
Entry
.
MEMBERSHIP_YEAR
,
...
...
@@ -143,6 +144,20 @@ class RegistrationTest(TestCase):
with
self
.
assertRaises
(
ValidationError
):
self
.
registration
.
clean
()
def
test_require_student_number_members
(
self
):
with
self
.
subTest
(
'No student number entered'
):
self
.
registration
.
student_number
=
None
with
self
.
assertRaisesMessage
(
ValidationError
,
"{'student_number': ['This field is required.']}"
):
self
.
registration
.
clean
()
with
self
.
subTest
(
'Type is benefactor'
):
self
.
registration
.
student_number
=
None
self
.
registration
.
membership_type
=
Membership
.
SUPPORTER
self
.
registration
.
clean
()
def
test_unique_username_user
(
self
):
self
.
registration
.
username
=
'johndoe'
self
.
registration
.
clean
()
...
...
Luko van der Maas
@lukomaas
mentioned in commit
a3bd07a6
·
Oct 03, 2018
mentioned in commit
a3bd07a6
mentioned in commit a3bd07a642de419250ed2995ab9dfea34747b1b9
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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