mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-18 14:02:15 +00:00
Generate a sample supervisor
This commit is contained in:
@@ -31,6 +31,7 @@ class Command(BaseCommand):
|
||||
self.setup_categories()
|
||||
self.setup_items()
|
||||
self.setup_levels()
|
||||
self.setup_supervisor()
|
||||
print("Done generating training data")
|
||||
|
||||
def setup_categories(self):
|
||||
@@ -66,3 +67,12 @@ class Command(BaseCommand):
|
||||
models.TrainingLevelRequirement.objects.create(level=supervisor, item=item, depth=random.choice(models.TrainingItemQualification.CHOICES)[0])
|
||||
self.levels.append(technician)
|
||||
self.levels.append(supervisor)
|
||||
|
||||
def setup_supervisor(self):
|
||||
supervisor = models.Profile.objects.create(username="supervisor", first_name="Super", last_name="Visor",
|
||||
initials="SV",
|
||||
email="supervisor@example.com", is_active=True,
|
||||
is_staff=True)
|
||||
supervisor.set_password('supervisor')
|
||||
supervisor.save()
|
||||
models.TrainingLevelQualification.objects.create(trainee=supervisor, level=self.levels[-1], confirmed_on=timezone.now())
|
||||
|
||||
@@ -12,7 +12,7 @@ class Trainee(Profile):
|
||||
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:
|
||||
if level_qualification.confirmed_on is not None and level_qualification.level.level >= TrainingLevel.SUPERVISOR:
|
||||
return True
|
||||
|
||||
def get_records_of_depth(self, depth):
|
||||
|
||||
Reference in New Issue
Block a user