diff --git a/training/forms.py b/training/forms.py index 78cb92f5..cc52f889 100644 --- a/training/forms.py +++ b/training/forms.py @@ -19,7 +19,7 @@ class QualificationForm(forms.ModelForm): super(QualificationForm, self).__init__(*args, **kwargs) self.fields['trainee'].initial = Profile.objects.get(pk=pk) self.fields['date'].initial = date.today() - + def clean_date(self): date = self.cleaned_data['date'] if date > date.today(): @@ -30,7 +30,9 @@ class QualificationForm(forms.ModelForm): supervisor = self.cleaned_data['supervisor'] if supervisor.pk == self.cleaned_data['trainee'].pk: raise forms.ValidationError('One may not supervise oneself...') - return supervisor # TODO also confirm that the supervisor is a Supervisor + if not supervisor.is_supervisor: + raise forms.ValidationError('Selected supervisor must actually *be* a supervisor...') + return supervisor class RequirementForm(forms.ModelForm): depth = forms.ChoiceField(choices=models.TrainingItemQualification.CHOICES) diff --git a/training/models.py b/training/models.py index 78508e0f..6307d61a 100644 --- a/training/models.py +++ b/training/models.py @@ -10,6 +10,7 @@ class Trainee(Profile): @property def is_supervisor(self): + # FIXME Efficiency for level_qualification in self.levels.select_related('level').all(): if confirmed_on is not None and level_qualification.level.level >= TrainingLevel.SUPERVISOR: return True diff --git a/training/templates/trainee_detail.html b/training/templates/trainee_detail.html index 0dd0c3e7..f29ce12f 100644 --- a/training/templates/trainee_detail.html +++ b/training/templates/trainee_detail.html @@ -12,7 +12,7 @@
Technical Assistant is conferred automatically when the item requirements are met. Technician status is also automatic, but notification of status should be made at the next general meeting, at which point 'approval' should be granted on the system. Supervisor status is not automatic and until signed off at a general meeting, does not count.Correct as of 7th July 2021, check the Training Policy.
+{{ level.description|truncatewords:30 }}