mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-18 14:02:15 +00:00
pep8
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from PyRIGS.decorators import user_passes_test_with_403
|
||||
|
||||
|
||||
def has_perm_or_supervisor(perm, login_url=None, oembed_view=None):
|
||||
return user_passes_test_with_403(lambda u: (hasattr(u, 'as_trainee') and u.as_trainee.is_supervisor) or u.has_perm(perm), login_url=login_url, oembed_view=oembed_view)
|
||||
|
||||
@@ -35,19 +35,27 @@ class Command(BaseCommand):
|
||||
def setup_groups(self):
|
||||
self.committee_group = Group.objects.create(name='Committee')
|
||||
|
||||
perms = ["add_trainingitemqualification", "change_trainingitemqualification", "delete_trainingitemqualification", "add_traininglevelqualification", "change_traininglevelqualification", "delete_traininglevelqualification", "add_traininglevelrequirement", "change_traininglevelrequirement", "delete_traininglevelrequirement"]
|
||||
perms = [
|
||||
"add_trainingitemqualification",
|
||||
"change_trainingitemqualification",
|
||||
"delete_trainingitemqualification",
|
||||
"add_traininglevelqualification",
|
||||
"change_traininglevelqualification",
|
||||
"delete_traininglevelqualification",
|
||||
"add_traininglevelrequirement",
|
||||
"change_traininglevelrequirement",
|
||||
"delete_traininglevelrequirement"]
|
||||
|
||||
for permId in perms:
|
||||
self.committee_group.permissions.add(Permission.objects.get(codename=permId))
|
||||
|
||||
self.committee_group.save()
|
||||
|
||||
|
||||
def setup_useful_profiles(self):
|
||||
supervisor = Profile.objects.create(username="supervisor", first_name="Super", last_name="Visor",
|
||||
initials="SV",
|
||||
email="supervisor@example.com", is_active=True,
|
||||
is_staff=True, is_approved=True)
|
||||
initials="SV",
|
||||
email="supervisor@example.com", is_active=True,
|
||||
is_staff=True, is_approved=True)
|
||||
supervisor.set_password('supervisor')
|
||||
supervisor.groups.add(Group.objects.get(name="Keyholders"))
|
||||
supervisor.save()
|
||||
@@ -61,8 +69,8 @@ class Command(BaseCommand):
|
||||
confirmed_by=models.Trainee.objects.first())
|
||||
|
||||
committee_user = Profile.objects.create(username="committee", first_name="Committee", last_name="Member",
|
||||
initials="CM",
|
||||
email="committee@example.com", is_active=True, is_approved=True)
|
||||
initials="CM",
|
||||
email="committee@example.com", is_active=True, is_approved=True)
|
||||
committee_user.groups.add(self.committee_group)
|
||||
supervisor.groups.add(Group.objects.get(name="Keyholders"))
|
||||
committee_user.set_password('committee')
|
||||
|
||||
@@ -124,7 +124,7 @@ class Command(BaseCommand):
|
||||
for child in root:
|
||||
depths = [("Training_Started", models.TrainingItemQualification.STARTED),
|
||||
("Training_Complete", models.TrainingItemQualification.COMPLETE),
|
||||
("Competency_Assessed", models.TrainingItemQualification.PASSED_OUT),]
|
||||
("Competency_Assessed", models.TrainingItemQualification.PASSED_OUT), ]
|
||||
|
||||
for (depth, depth_index) in depths:
|
||||
if child.find('{}_Date'.format(depth)) is not None:
|
||||
|
||||
@@ -19,10 +19,9 @@ class Trainee(Profile, RevisionMixin):
|
||||
@property
|
||||
def is_technician(self):
|
||||
return self.level_qualifications.exclude(confirmed_on=None).select_related('level') \
|
||||
.filter(level__level=TrainingLevel.TECHNICIAN) \
|
||||
.exclude(level__department=TrainingLevel.HAULAGE) \
|
||||
.exclude(level__department__isnull=True).exists()
|
||||
|
||||
.filter(level__level=TrainingLevel.TECHNICIAN) \
|
||||
.exclude(level__department=TrainingLevel.HAULAGE) \
|
||||
.exclude(level__department__isnull=True).exists()
|
||||
|
||||
@property
|
||||
def is_supervisor(self):
|
||||
|
||||
@@ -12,7 +12,7 @@ urlpatterns = [
|
||||
path('trainee/<int:pk>/',
|
||||
has_perm_or_supervisor('RIGS.view_profile')(views.TraineeDetail.as_view()),
|
||||
name='trainee_detail'),
|
||||
path('trainee/<int:pk>/history', has_perm_or_supervisor('RIGS.view_profile')(VersionHistory.as_view()), name='trainee_history', kwargs={'model': models.Trainee, 'app': 'training'}), # Not picked up automatically because proxy model (I think)
|
||||
path('trainee/<int:pk>/history', has_perm_or_supervisor('RIGS.view_profile')(VersionHistory.as_view()), name='trainee_history', kwargs={'model': models.Trainee, 'app': 'training'}), # Not picked up automatically because proxy model (I think)
|
||||
path('trainee/<int:pk>/add_qualification/', has_perm_or_supervisor('training.add_trainingitemqualificaiton')(views.AddQualification.as_view()),
|
||||
name='add_qualification'),
|
||||
path('trainee/<int:pk>/edit_qualification/', has_perm_or_supervisor('training.change_trainingitemqualification')(views.EditQualification.as_view()),
|
||||
|
||||
Reference in New Issue
Block a user