Revision bd92cd64 edumanage/forms.py

b/edumanage/forms.py
18 18

  
19 19
    class Meta:
20 20
        model = InstServer
21
    
22
    def clean_ertype(self):
23
        ertype = self.cleaned_data['ertype']
24
        institution = self.cleaned_data['instid']
25
        inst_type = institution.institutiondetails.ertype
26
        type_list = [inst_type]
27
        if inst_type == 3:
28
            type_list = [1, 2, 3]
29
        if ertype:
30
            if ertype not in type_list:
31
                raise forms.ValidationError('Server type cannot be different than institution type (%s)' %dict(self.fields['ertype'].choices)[inst_type])
32
            return self.cleaned_data["ertype"]
33
        else:
34
            raise forms.ValidationError('This field is required.')
21 35

  
22 36
class ContactForm(forms.ModelForm):
23 37

  

Also available in: Unified diff