mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
System for allowing certain TrainingCategories to be trained by certain levels, regardless of supervisor status
I.e. the haulage department, ref #482. As generic as I can make it I think.
This commit is contained in:
@@ -23,9 +23,13 @@ class QualificationForm(forms.ModelForm):
|
||||
|
||||
def clean_supervisor(self):
|
||||
supervisor = self.cleaned_data['supervisor']
|
||||
item = self.cleaned_data['item']
|
||||
if supervisor.pk == self.cleaned_data['trainee'].pk:
|
||||
raise forms.ValidationError('One may not supervise oneself...')
|
||||
if not supervisor.is_supervisor:
|
||||
if item.category.training_level:
|
||||
if not supervisor.level_qualifications.filter(level=item.category.training_level):
|
||||
raise forms.ValidationError('Selected supervising person is missing requisite training level to train in this department')
|
||||
elif not supervisor.is_supervisor:
|
||||
raise forms.ValidationError('Selected supervisor must actually *be* a supervisor...')
|
||||
return supervisor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user