From 2f746c9fd9835320ef4c689b9488b087435c2450 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 28 Mar 2018 11:18:00 -0400 Subject: [PATCH 1/3] Complete removal of InitialPlaybookRun --- .../linkout/organizations-linkout.route.js | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js index 20f8b6a6c3..deae3ddf13 100644 --- a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js +++ b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js @@ -216,6 +216,78 @@ let lists = [{ } ] } +}, { + name: 'organizations.job_templates', + url: '/:organization_id/job_templates', + searchPrefix: 'job_template', + views: { + 'form': { + controller: OrganizationsJobTemplates, + templateProvider: function(OrgJobTemplateList, generateList) { + let html = generateList.build({ + list: OrgJobTemplateList, + mode: 'edit', + cancelButton: true + }); + return generateList.wrapPanel(html); + }, + }, + }, + params: { + template_search: { + value: { + or__project__organization: null, + or__inventory__organization: null, + page_size: 20 + }, + dynamic: true + } + }, + data: { + activityStream: true, + activityStreamTarget: 'organization', + socket: { + "groups": { + "jobs": ["status_changed"] + } + } + }, + ncyBreadcrumb: { + parent: "organizations.edit", + label: N_("JOB TEMPLATES") + }, + resolve: { + features: ['FeaturesService', function(FeaturesService) { + return FeaturesService.get(); + }], + OrgJobTemplateList: ['TemplateList', 'GetBasePath', '$stateParams', function(TemplateList) { + let list = _.cloneDeep(TemplateList); + delete list.actions; + // @issue Why is the delete action unavailable in this view? + delete list.fieldActions.delete; + delete list.fields.type; + list.listTitle = N_('Job Templates') + ` | {{ name }}`; + list.emptyListText = "This list is populated by job templates added from the Job Templates section"; + list.iterator = 'template'; + list.name = 'job_templates'; + list.basePath = "job_templates"; + list.fields.smart_status.ngInclude = "'/static/partials/organizations-job-template-smart-status.html'"; + list.fields.name.ngHref = '#/templates/job_template/{{template.id}}'; + list.fieldActions.schedule.ngClick = 'scheduleJob(template.id)'; + list.fieldActions.copy.ngClick = 'copyTemplate(template.id)'; + list.fieldActions.edit.ngClick = "editJobTemplate(template.id)"; + list.fieldActions.view.ngClick = "editJobTemplate(template.id)"; + return list; + }], + OrgJobTemplateDataset: ['OrgJobTemplateList', 'QuerySet', '$stateParams', 'GetBasePath', + function(list, qs, $stateParams, GetBasePath) { + let path = GetBasePath(list.name); + $stateParams.template_search.or__project__organization = $stateParams.organization_id; + $stateParams.template_search.or__inventory__organization = $stateParams.organization_id; + return qs.search(path, $stateParams.template_search); + } + ] + } }, { name: 'organizations.admins', url: '/:organization_id/admins', From 881688dd776f519b3def96cc243f94415f545efa Mon Sep 17 00:00:00 2001 From: adamscmRH Date: Tue, 3 Apr 2018 11:57:47 -0400 Subject: [PATCH 2/3] fix authentication order --- awx/settings/defaults.py | 3 +- .../linkout/organizations-linkout.route.js | 72 ------------------- 2 files changed, 1 insertion(+), 74 deletions(-) diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 645947eb60..013f831492 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -289,9 +289,8 @@ REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'awx.api.pagination.Pagination', 'PAGE_SIZE': 25, 'DEFAULT_AUTHENTICATION_CLASSES': ( - 'awx.api.authentication.SessionAuthentication', 'awx.api.authentication.LoggedOAuth2Authentication', - # 'awx.api.authentication.SessionAuthentication', + 'awx.api.authentication.SessionAuthentication', 'awx.api.authentication.LoggedBasicAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ( diff --git a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js index deae3ddf13..20f8b6a6c3 100644 --- a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js +++ b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js @@ -216,78 +216,6 @@ let lists = [{ } ] } -}, { - name: 'organizations.job_templates', - url: '/:organization_id/job_templates', - searchPrefix: 'job_template', - views: { - 'form': { - controller: OrganizationsJobTemplates, - templateProvider: function(OrgJobTemplateList, generateList) { - let html = generateList.build({ - list: OrgJobTemplateList, - mode: 'edit', - cancelButton: true - }); - return generateList.wrapPanel(html); - }, - }, - }, - params: { - template_search: { - value: { - or__project__organization: null, - or__inventory__organization: null, - page_size: 20 - }, - dynamic: true - } - }, - data: { - activityStream: true, - activityStreamTarget: 'organization', - socket: { - "groups": { - "jobs": ["status_changed"] - } - } - }, - ncyBreadcrumb: { - parent: "organizations.edit", - label: N_("JOB TEMPLATES") - }, - resolve: { - features: ['FeaturesService', function(FeaturesService) { - return FeaturesService.get(); - }], - OrgJobTemplateList: ['TemplateList', 'GetBasePath', '$stateParams', function(TemplateList) { - let list = _.cloneDeep(TemplateList); - delete list.actions; - // @issue Why is the delete action unavailable in this view? - delete list.fieldActions.delete; - delete list.fields.type; - list.listTitle = N_('Job Templates') + ` | {{ name }}`; - list.emptyListText = "This list is populated by job templates added from the Job Templates section"; - list.iterator = 'template'; - list.name = 'job_templates'; - list.basePath = "job_templates"; - list.fields.smart_status.ngInclude = "'/static/partials/organizations-job-template-smart-status.html'"; - list.fields.name.ngHref = '#/templates/job_template/{{template.id}}'; - list.fieldActions.schedule.ngClick = 'scheduleJob(template.id)'; - list.fieldActions.copy.ngClick = 'copyTemplate(template.id)'; - list.fieldActions.edit.ngClick = "editJobTemplate(template.id)"; - list.fieldActions.view.ngClick = "editJobTemplate(template.id)"; - return list; - }], - OrgJobTemplateDataset: ['OrgJobTemplateList', 'QuerySet', '$stateParams', 'GetBasePath', - function(list, qs, $stateParams, GetBasePath) { - let path = GetBasePath(list.name); - $stateParams.template_search.or__project__organization = $stateParams.organization_id; - $stateParams.template_search.or__inventory__organization = $stateParams.organization_id; - return qs.search(path, $stateParams.template_search); - } - ] - } }, { name: 'organizations.admins', url: '/:organization_id/admins', From 0f046338ac2cee46c00d4545c50e705b111ea340 Mon Sep 17 00:00:00 2001 From: adamscmRH Date: Fri, 6 Apr 2018 08:47:54 -0400 Subject: [PATCH 3/3] check ParseError fix --- awx/api/generics.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/awx/api/generics.py b/awx/api/generics.py index cf5b2002ee..e12949515b 100644 --- a/awx/api/generics.py +++ b/awx/api/generics.py @@ -23,7 +23,7 @@ from django.contrib.auth import views as auth_views # Django REST Framework from rest_framework.authentication import get_authorization_header -from rest_framework.exceptions import PermissionDenied, AuthenticationFailed +from rest_framework.exceptions import PermissionDenied, AuthenticationFailed, ParseError from rest_framework import generics from rest_framework.response import Response from rest_framework import status @@ -165,6 +165,9 @@ class APIView(views.APIView): request.drf_request_user = getattr(drf_request, 'user', False) except AuthenticationFailed: request.drf_request_user = None + except ParseError as exc: + request.drf_request_user = None + self.__init_request_error__ = exc return drf_request def finalize_response(self, request, response, *args, **kwargs): @@ -174,6 +177,8 @@ class APIView(views.APIView): if response.status_code >= 400: status_msg = "status %s received by user %s attempting to access %s from %s" % \ (response.status_code, request.user, request.path, request.META.get('REMOTE_ADDR', None)) + if hasattr(self, '__init_request_error__'): + response = self.handle_exception(self.__init_request_error__) if response.status_code == 401: logger.info(status_msg) else: