Commit 215124c3 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

'None' is not considered as 'a Room' when calculating student occupancy caps

parent 57fa46cd
...@@ -78,11 +78,12 @@ class StudentUpdateForm(forms.Form): ...@@ -78,11 +78,12 @@ class StudentUpdateForm(forms.Form):
def clean(self): def clean(self):
cleaned_data = super(StudentUpdateForm, self).clean() cleaned_data = super(StudentUpdateForm, self).clean()
form_room = cleaned_data.get('room') form_room = cleaned_data.get('room')
students_in_room = Student.objects.filter(room=form_room).count() if not(form_room is None):
#print(students_in_room) students_in_room = Student.objects.filter(room=form_room).count()
# like in bookshare, I have no idea why the form errors don't display. #print(students_in_room)
if students_in_room > 12: # like in bookshare, I have no idea why the form errors don't display.
raise ValidationError(_('Too many students in room (%d).' % students_in_room), code='invalid') if students_in_room > 12:
raise ValidationError(_('Too many students in room (%d).' % students_in_room), code='invalid')
def is_valid(self): def is_valid(self):
# errors are not printed in form.as_p? # errors are not printed in form.as_p?
...@@ -117,11 +118,12 @@ class WelcomePrivacyForm(forms.ModelForm): ...@@ -117,11 +118,12 @@ class WelcomePrivacyForm(forms.ModelForm):
def clean(self): def clean(self):
cleaned_data = super(WelcomePrivacyForm, self).clean() cleaned_data = super(WelcomePrivacyForm, self).clean()
form_room = cleaned_data.get('room') form_room = cleaned_data.get('room')
students_in_room = Student.objects.filter(room=form_room).count() if not(form_room is None):
#print(students_in_room) students_in_room = Student.objects.filter(room=form_room).count()
# like in bookshare, I have no idea why the form errors don't display. #print(students_in_room)
if students_in_room > 12: # like in bookshare, I have no idea why the form errors don't display.
raise ValidationError(_('Too many students in room (%d).' % students_in_room), code='invalid') if students_in_room > 12:
raise ValidationError(_('Too many students in room (%d).' % students_in_room), code='invalid')
class Meta: class Meta:
model = Student model = Student
......
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