From 3e8aaa4b5e69306a0cbc9475306381cef17e9df9 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Thu, 9 Jun 2016 09:55:17 -0400 Subject: [PATCH] Fix an issue showing attach/detach docs There's a condition in sub_list_create_api_view.md template that controls whether or not the attach/detach documentation is shown for sublist elements that support it. Looks like it's been this way for a while. This updates that condition to work anywhere it's needed --- awx/api/generics.py | 7 +++++++ awx/api/templates/api/sub_list_create_api_view.md | 2 +- awx/api/views.py | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/awx/api/generics.py b/awx/api/generics.py index fe1ecd5659..37b4561bc1 100644 --- a/awx/api/generics.py +++ b/awx/api/generics.py @@ -360,6 +360,13 @@ class SubListCreateAttachDetachAPIView(SubListCreateAPIView): # Base class for a sublist view that allows for creating subobjects and # attaching/detaching them from the parent. + def get_description_context(self): + d = super(SubListCreateAttachDetachAPIView, self).get_description_context() + d.update({ + "has_attach": True, + }) + return d + def attach(self, request, *args, **kwargs): created = False parent = self.get_parent_object() diff --git a/awx/api/templates/api/sub_list_create_api_view.md b/awx/api/templates/api/sub_list_create_api_view.md index 23677f649b..75c5940f4d 100644 --- a/awx/api/templates/api/sub_list_create_api_view.md +++ b/awx/api/templates/api/sub_list_create_api_view.md @@ -12,7 +12,7 @@ fields to create a new {{ model_verbose_name }} associated with this {% block post_create %}{% endblock %} -{% if view.attach %} +{% if has_attach|default:False %} {% if parent_key %} # Remove {{ parent_model_verbose_name|title }} {{ model_verbose_name_plural|title }}: diff --git a/awx/api/views.py b/awx/api/views.py index d7ead9aff0..dcc389c678 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -2453,7 +2453,6 @@ class JobTemplateLabelList(SubListCreateAttachDetachAPIView, DeleteLastUnattachL serializer_class = LabelSerializer parent_model = JobTemplate relationship = 'labels' - parent_key = 'job_template' class JobTemplateCallback(GenericAPIView):