1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Revert ScheduleAccess can_* methods to route through other *Access classes

This takes care of all the polymorphic cases, which we'd have to
otherwise handle
This commit is contained in:
Akita Noek 2016-03-17 08:53:40 -04:00
parent c0245317b3
commit 3ca016faaf

View File

@ -1142,7 +1142,8 @@ class ScheduleAccess(BaseAccess):
if self.user.is_superuser:
return True
if obj and obj.unified_job_template:
return obj.unified_job_template.accessible_by(self.user, {'read':True})
job_class = obj.unified_job_template
return self.user.can_access(type(job_class), 'read', obj.unified_job_template)
else:
return False
@ -1152,7 +1153,7 @@ class ScheduleAccess(BaseAccess):
pk = get_pk_from_dict(data, 'unified_job_template')
obj = get_object_or_400(UnifiedJobTemplate, pk=pk)
if obj:
return obj.accessible_by(self.user, {'read':True, 'update':True, 'write':True})
return self.user.can_access(type(obj), 'change', obj, None)
else:
return False
@ -1160,7 +1161,8 @@ class ScheduleAccess(BaseAccess):
if self.user.is_superuser:
return True
if obj and obj.unified_job_template:
return obj.unified_job_template.accessible_by(self.user, {'read':True, 'update':True, 'write':True})
job_class = obj.unified_job_template
return self.user.can_access(type(job_class), 'change', job_class, None)
else:
return False
@ -1168,7 +1170,8 @@ class ScheduleAccess(BaseAccess):
if self.user.is_superuser:
return True
if obj and obj.unified_job_template:
return obj.unified_job_template.accessible_by(self.user, {'read':True, 'update':True, 'write':True})
job_class = obj.unified_job_template
return self.user.can_access(type(job_class), 'change', job_class, None)
else:
return False