prototype for new copy GET details

This commit is contained in:
AlanCoding
2017-01-11 12:23:57 -05:00
parent e69dc0f36e
commit 2c97425291
3 changed files with 29 additions and 19 deletions

View File

@@ -2906,12 +2906,16 @@ class WorkflowJobTemplateCopy(WorkflowsEnforcementMixin, GenericAPIView):
def get(self, request, *args, **kwargs):
obj = self.get_object()
data = {}
copy_TF, messages = request.user.can_access_with_errors(self.model, 'copy', obj)
data['can_copy'] = copy_TF
data['warnings'] = messages
if not copy_TF:
data['warnings'] = _('You do not have permission to make a copy.')
can_copy, messages = request.user.can_access_with_errors(self.model, 'copy', obj)
data = {
'can_copy': can_copy, 'can_copy_without_user_input': can_copy,
'templates_unable_to_copy': [] if can_copy else ['all'],
'credentials_unable_to_copy': [] if can_copy else ['all'],
'inventories_unable_to_copy': [] if can_copy else ['all']
}
if messages and can_copy:
data['can_copy_without_user_input'] = False
data.update(messages)
return Response(data)
def post(self, request, *args, **kwargs):