Fix an issue where non-org-admin users with appropriate job template

permissions were not able to view or edit schedule details
This commit is contained in:
Matthew Jones 2015-01-21 13:49:04 -05:00
parent 556d7a8ac6
commit 16a9af0803
2 changed files with 4 additions and 3 deletions

View File

@ -1318,8 +1318,8 @@ class ScheduleAccess(BaseAccess):
if self.user.is_superuser:
return True
if obj and obj.unified_job_template:
job_class = obj.unified_job_template._get_unified_job_class()
return self.user.can_access(job_class, 'read', obj.unified_job_template)
job_class = obj.unified_job_template
return self.user.can_access(type(job_class), 'read', obj.unified_job_template)
else:
return False
@ -1338,7 +1338,7 @@ class ScheduleAccess(BaseAccess):
return True
if obj and obj.unified_job_template:
job_class = obj.unified_job_template
return self.user.can_access(type(job_class), 'change', job_class, data)
return self.user.can_access(type(job_class), 'change', job_class, None)
else:
return False

View File

@ -180,6 +180,7 @@ class ScheduleTest(BaseTest):
with self.current_user(self.normal_django_user):
data = self.put(new_schedule_url, data=data, expect=200)
self.assertNotEqual(data['next_run'], None)
#TODO: Test path needed for non org-admin users, but rather regular users who have permission to create the JT associated with the Schedule
def test_infinite_schedule(self):
first_url = reverse('api:inventory_source_schedules_list', args=(self.first_inventory_source.pk,))