diff --git a/training/management/commands/generateSampleTrainingData.py b/training/management/commands/generateSampleTrainingData.py index 3498485a..1ed90708 100644 --- a/training/management/commands/generateSampleTrainingData.py +++ b/training/management/commands/generateSampleTrainingData.py @@ -90,4 +90,4 @@ class Command(BaseCommand): is_staff=True) supervisor.set_password('supervisor') supervisor.save() - models.TrainingLevelQualification.objects.create(trainee=supervisor, level=self.levels[-1], confirmed_on=timezone.now()) + models.TrainingLevelQualification.objects.create(trainee=supervisor, level=models.TrainingLevel.objects.filter(level__gte=models.TrainingLevel.SUPERVISOR).exclude(department=models.TrainingLevel.HAULAGE).first(), confirmed_on=timezone.now()) diff --git a/training/models.py b/training/models.py index 845daa9f..c858f7e7 100644 --- a/training/models.py +++ b/training/models.py @@ -16,12 +16,16 @@ class Trainee(Profile): def level_qualifications(self, only_confirmed=False): levels = self.levels.all() if only_confirmed: - levels = levels.filter(confirmed_on__isnull=False) + levels = levels.exclude(confirmed_on__isnull=True) return levels.select_related('level') @property def is_supervisor(self): - return self.level_qualifications(True).filter(level__gte=TrainingLevel.SUPERVISOR).exists() + return self.level_qualifications(True).filter(level__gte=TrainingLevel.SUPERVISOR).exclude(level__department=TrainingLevel.HAULAGE).exists() + + @property + def is_driver(self): + return self.level_qualifications(True).filter(level__department=TrainingLevel.HAULAGE).exists() def get_records_of_depth(self, depth): return self.qualifications_obtained.filter(depth=depth).select_related('item', 'trainee', 'supervisor') @@ -123,12 +127,13 @@ class TrainingLevel(models.Model, RevisionMixin): (TECHNICIAN, 'Technician'), (SUPERVISOR, 'Supervisor'), ) + HAULAGE = 4 DEPARTMENTS = ( (0, 'Sound'), (1, 'Lighting'), (2, 'Power'), (3, 'Rigging'), - (4, 'Haulage'), + (HAULAGE, 'Haulage'), ) department = models.IntegerField(choices=DEPARTMENTS, null=True) # N.B. Technical Assistant does not have a department level = models.IntegerField(choices=CHOICES) diff --git a/training/templates/base_training.html b/training/templates/base_training.html index 0640ca75..60e655c2 100644 --- a/training/templates/base_training.html +++ b/training/templates/base_training.html @@ -10,19 +10,26 @@ {% if user.is_authenticated %}