mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-10 00:39:40 +00:00
pep8
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from PyRIGS.decorators import user_passes_test_with_403
|
from PyRIGS.decorators import user_passes_test_with_403
|
||||||
|
|
||||||
|
|
||||||
def has_perm_or_supervisor(perm, login_url=None, oembed_view=None):
|
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)
|
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,14 +35,22 @@ class Command(BaseCommand):
|
|||||||
def setup_groups(self):
|
def setup_groups(self):
|
||||||
self.committee_group = Group.objects.create(name='Committee')
|
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:
|
for permId in perms:
|
||||||
self.committee_group.permissions.add(Permission.objects.get(codename=permId))
|
self.committee_group.permissions.add(Permission.objects.get(codename=permId))
|
||||||
|
|
||||||
self.committee_group.save()
|
self.committee_group.save()
|
||||||
|
|
||||||
|
|
||||||
def setup_useful_profiles(self):
|
def setup_useful_profiles(self):
|
||||||
supervisor = Profile.objects.create(username="supervisor", first_name="Super", last_name="Visor",
|
supervisor = Profile.objects.create(username="supervisor", first_name="Super", last_name="Visor",
|
||||||
initials="SV",
|
initials="SV",
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class Trainee(Profile, RevisionMixin):
|
|||||||
.exclude(level__department=TrainingLevel.HAULAGE) \
|
.exclude(level__department=TrainingLevel.HAULAGE) \
|
||||||
.exclude(level__department__isnull=True).exists()
|
.exclude(level__department__isnull=True).exists()
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_supervisor(self):
|
def is_supervisor(self):
|
||||||
return self.level_qualifications.exclude(confirmed_on=None).select_related('level') \
|
return self.level_qualifications.exclude(confirmed_on=None).select_related('level') \
|
||||||
|
|||||||
Reference in New Issue
Block a user