From c11b870084b0905100cbe2b8b406f28bfef09b4c Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Wed, 19 Jul 2017 14:16:31 -0400 Subject: [PATCH] remove job_type scan from options * Need to keep the scan job in job_type for migrations so just remove it from the constructed OPTIONS --- awx/api/metadata.py | 16 ++++++++++++++++ awx/api/views.py | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/awx/api/metadata.py b/awx/api/metadata.py index cd1de70a09..db189951f3 100644 --- a/awx/api/metadata.py +++ b/awx/api/metadata.py @@ -236,3 +236,19 @@ class RoleMetadata(Metadata): "disassociate": {"type": "integer", "label": "Disassociate", "help_text": "Provide to remove this role."}, } return metadata + + +# TODO: Tower 3.3 remove class and all uses in views.py when API v1 is removed +class JobTypeMetadata(Metadata): + def get_field_info(self, field): + res = super(JobTypeMetadata, self).get_field_info(field) + + if field.field_name == 'job_type': + index = 0 + for choice in res['choices']: + if choice[0] == 'scan': + res['choices'].pop(index) + break + index += 1 + return res + diff --git a/awx/api/views.py b/awx/api/views.py index dfb57da156..8b865a4e1c 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -78,7 +78,7 @@ from awx.main.utils.filters import SmartFilter from awx.api.permissions import * # noqa from awx.api.renderers import * # noqa from awx.api.serializers import * # noqa -from awx.api.metadata import RoleMetadata +from awx.api.metadata import RoleMetadata, JobTypeMetadata from awx.main.consumers import emit_channel_notification from awx.main.models.unified_jobs import ACTIVE_STATES from awx.main.scheduler.tasks import run_job_complete @@ -2713,6 +2713,7 @@ class InventoryUpdateNotificationsList(SubListAPIView): class JobTemplateList(ListCreateAPIView): model = JobTemplate + metadata_class = JobTypeMetadata serializer_class = JobTemplateSerializer always_allow_superuser = False capabilities_prefetch = [ @@ -2731,6 +2732,7 @@ class JobTemplateList(ListCreateAPIView): class JobTemplateDetail(RetrieveUpdateDestroyAPIView): model = JobTemplate + metadata_class = JobTypeMetadata serializer_class = JobTemplateSerializer always_allow_superuser = False @@ -3731,12 +3733,14 @@ class SystemJobTemplateNotificationTemplatesSuccessList(SubListCreateAttachDetac class JobList(ListCreateAPIView): model = Job + metadata_class = JobTypeMetadata serializer_class = JobListSerializer class JobDetail(RetrieveUpdateDestroyAPIView): model = Job + metadata_class = JobTypeMetadata serializer_class = JobSerializer def update(self, request, *args, **kwargs):