add validation of accommodation codes
This commit is contained in:
@@ -179,7 +179,8 @@ class Command(BaseCommand):
|
||||
if (len(form.errors) > 0):
|
||||
print "Field Form errors encountered:"
|
||||
for fielderror in form.errors:
|
||||
print "Field Form Error: %s" % fielderror
|
||||
for msg in form.errors[fielderror]:
|
||||
print "Field Form Error: {} -- {}".format(fielderror, msg)
|
||||
if (len(form.non_field_errors()) > 0):
|
||||
print "Non-field Form errors encountered:"
|
||||
for nonfielderror in form.non_field_errors:
|
||||
|
||||
@@ -552,7 +552,15 @@ class TestCenterRegistrationForm(ModelForm):
|
||||
registration.save()
|
||||
log.info("Updated registration information for user's test center exam registration: username \"{}\" course \"{}\", examcode \"{}\"".format(registration.testcenter_user.user.username, registration.course_id, registration.exam_series_code))
|
||||
|
||||
# TODO: add validation code for values added to accommodation_code field.
|
||||
def clean_accommodation_code(self):
|
||||
code = self.cleaned_data['accommodation_code']
|
||||
if code:
|
||||
code = code.upper()
|
||||
codes = code.split('*')
|
||||
for codeval in codes:
|
||||
if codeval not in ACCOMMODATION_CODE_DICT:
|
||||
raise forms.ValidationError(u'Invalid accommodation code specified: "{}"'.format(codeval))
|
||||
return code
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user