From 0de53886dad62c2ada8088322b399d758f68e918 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 10 Nov 2014 14:44:09 -0500 Subject: [PATCH] Disallow multiple schedules for System Job Templates --- awx/api/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/awx/api/views.py b/awx/api/views.py index 08015cdfc6..0afb08f666 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -1766,6 +1766,12 @@ class SystemJobTemplateSchedulesList(SubListCreateAPIView): relationship = 'schedules' parent_key = 'unified_job_template' + def post(self, request, *args, **kwargs): + system_job = self.get_parent_object() + if system_job.schedules.count() > 0: + return Response({"error": "Multiple schedules for Systems Jobs is not allowed"}, status=status.HTTP_400_BAD_REQUEST) + return super(SystemJobTemplateSchedulesList, self).post(request, *args, **kwargs) + class SystemJobTemplateJobsList(SubListAPIView): model = SystemJob