Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
215124c3
Commit
215124c3
authored
Dec 10, 2015
by
Daniel W Bond
Browse files
'None' is not considered as 'a Room' when calculating student occupancy caps
parent
57fa46cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
roomlist/accounts/forms.py
View file @
215124c3
...
...
@@ -78,11 +78,12 @@ class StudentUpdateForm(forms.Form):
def
clean
(
self
):
cleaned_data
=
super
(
StudentUpdateForm
,
self
).
clean
()
form_room
=
cleaned_data
.
get
(
'room'
)
students_in_room
=
Student
.
objects
.
filter
(
room
=
form_room
).
count
()
#print(students_in_room)
# like in bookshare, I have no idea why the form errors don't display.
if
students_in_room
>
12
:
raise
ValidationError
(
_
(
'Too many students in room (%d).'
%
students_in_room
),
code
=
'invalid'
)
if
not
(
form_room
is
None
):
students_in_room
=
Student
.
objects
.
filter
(
room
=
form_room
).
count
()
#print(students_in_room)
# like in bookshare, I have no idea why the form errors don't display.
if
students_in_room
>
12
:
raise
ValidationError
(
_
(
'Too many students in room (%d).'
%
students_in_room
),
code
=
'invalid'
)
def
is_valid
(
self
):
# errors are not printed in form.as_p?
...
...
@@ -117,11 +118,12 @@ class WelcomePrivacyForm(forms.ModelForm):
def
clean
(
self
):
cleaned_data
=
super
(
WelcomePrivacyForm
,
self
).
clean
()
form_room
=
cleaned_data
.
get
(
'room'
)
students_in_room
=
Student
.
objects
.
filter
(
room
=
form_room
).
count
()
#print(students_in_room)
# like in bookshare, I have no idea why the form errors don't display.
if
students_in_room
>
12
:
raise
ValidationError
(
_
(
'Too many students in room (%d).'
%
students_in_room
),
code
=
'invalid'
)
if
not
(
form_room
is
None
):
students_in_room
=
Student
.
objects
.
filter
(
room
=
form_room
).
count
()
#print(students_in_room)
# like in bookshare, I have no idea why the form errors don't display.
if
students_in_room
>
12
:
raise
ValidationError
(
_
(
'Too many students in room (%d).'
%
students_in_room
),
code
=
'invalid'
)
class
Meta
:
model
=
Student
...
...
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