mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-22 07:52:15 +00:00
Add basic validation of item prerequisites
Currently throws the worlds most unhelpful error message...
This commit is contained in:
@@ -16,6 +16,13 @@ class QualificationForm(forms.ModelForm):
|
||||
self.fields['trainee'].initial = Profile.objects.get(pk=pk)
|
||||
self.fields['date'].widget.format = '%Y-%m-%d'
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
item = cleaned_data.get('item')
|
||||
trainee = cleaned_data.get('trainee')
|
||||
if not item.user_has_requirements(trainee):
|
||||
self.add_error('item', 'Missing prerequisites')
|
||||
|
||||
def clean_date(self):
|
||||
date = self.cleaned_data['date']
|
||||
if date > date.today():
|
||||
|
||||
Reference in New Issue
Block a user