mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-21 07:22:14 +00:00
Migrate to is_supervisor being a database field
More efficient, but it does reduce app seperation. Probably not an issue for us!
This commit is contained in:
@@ -23,13 +23,6 @@ class Trainee(Profile, RevisionMixin):
|
||||
.exclude(level__department=TrainingLevel.HAULAGE) \
|
||||
.exclude(level__department__isnull=True).exists()
|
||||
|
||||
@property
|
||||
def is_supervisor(self):
|
||||
return self.level_qualifications.exclude(confirmed_on=None).select_related('level') \
|
||||
.filter(level__level__gte=TrainingLevel.SUPERVISOR) \
|
||||
.exclude(level__department=TrainingLevel.HAULAGE) \
|
||||
.exclude(level__department__isnull=True).exists()
|
||||
|
||||
@property
|
||||
def is_driver(self):
|
||||
return self.level_qualifications.all().exclude(confirmed_on=None).select_related('level').filter(level__department=TrainingLevel.HAULAGE).exists()
|
||||
@@ -266,6 +259,11 @@ class TrainingLevelQualification(models.Model, RevisionMixin):
|
||||
def get_icon(self):
|
||||
return self.level.get_icon
|
||||
|
||||
def clean(self):
|
||||
if level.level >= TrainingLevel.SUPERVISOR and level.department != TrainingLevel.HAULAGE:
|
||||
trainee.is_supervisor = True
|
||||
trainee.save()
|
||||
|
||||
def __str__(self):
|
||||
if self.level.is_common_competencies:
|
||||
return "{} is qualified in the {}".format(self.trainee, self.level)
|
||||
|
||||
Reference in New Issue
Block a user