fix a bug in OPTIONS /api/v2/schedules/

a side effect of this bug is that `awx schedules create` doesn't work
properly for non-admin users (i.e., users who have execute access for
a JT)

see: https://github.com/ansible/awx/issues/5717
This commit is contained in:
Ryan Petrello
2020-03-05 14:43:54 -05:00
parent e34e88549f
commit cd1ff6b16a
2 changed files with 45 additions and 0 deletions

View File

@@ -2429,6 +2429,11 @@ class ScheduleAccess(BaseAccess):
def can_add(self, data):
if not JobLaunchConfigAccess(self.user).can_add(data):
return False
if not data:
return UnifiedJobTemplate.accessible_pk_qs(
self.user, 'execute_role'
).exists()
return self.check_related('unified_job_template', UnifiedJobTemplate, data, role_field='execute_role', mandatory=True)
@check_superuser