Commit bd92cd64 authored by Leonidas Poulopoulos's avatar Leonidas Poulopoulos

Added clean method on ertype field under InstServer form

parent 4f6197de
......@@ -18,6 +18,20 @@ class InstServerForm(forms.ModelForm):
class Meta:
model = InstServer
def clean_ertype(self):
ertype = self.cleaned_data['ertype']
institution = self.cleaned_data['instid']
inst_type = institution.institutiondetails.ertype
type_list = [inst_type]
if inst_type == 3:
type_list = [1, 2, 3]
if ertype:
if ertype not in type_list:
raise forms.ValidationError('Server type cannot be different than institution type (%s)' %dict(self.fields['ertype'].choices)[inst_type])
return self.cleaned_data["ertype"]
else:
raise forms.ValidationError('This field is required.')
class ContactForm(forms.ModelForm):
......
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