mirror of
https://github.com/ansible/awx.git
synced 2026-03-28 22:35:08 -02:30
a workable version of the new copy GET schema implemented
This commit is contained in:
@@ -2907,12 +2907,12 @@ class WorkflowJobTemplateCopy(WorkflowsEnforcementMixin, GenericAPIView):
|
|||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
can_copy, messages = request.user.can_access_with_errors(self.model, 'copy', obj)
|
can_copy, messages = request.user.can_access_with_errors(self.model, 'copy', obj)
|
||||||
data = {
|
data = OrderedDict([
|
||||||
'can_copy': can_copy, 'can_copy_without_user_input': can_copy,
|
('can_copy', can_copy), ('can_copy_without_user_input', can_copy),
|
||||||
'templates_unable_to_copy': [] if can_copy else ['all'],
|
('templates_unable_to_copy', [] if can_copy else ['all']),
|
||||||
'credentials_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']
|
('inventories_unable_to_copy', [] if can_copy else ['all'])
|
||||||
}
|
])
|
||||||
if messages and can_copy:
|
if messages and can_copy:
|
||||||
data['can_copy_without_user_input'] = False
|
data['can_copy_without_user_input'] = False
|
||||||
data.update(messages)
|
data.update(messages)
|
||||||
|
|||||||
@@ -120,13 +120,11 @@ class TestWorkflowJobAccess:
|
|||||||
access = WorkflowJobTemplateAccess(rando, save_messages=True)
|
access = WorkflowJobTemplateAccess(rando, save_messages=True)
|
||||||
assert not access.can_copy(wfjt)
|
assert not access.can_copy(wfjt)
|
||||||
warnings = access.messages
|
warnings = access.messages
|
||||||
assert 1 in warnings
|
assert 'inventories_unable_to_copy' in warnings
|
||||||
assert 'inventory' in warnings[1]
|
|
||||||
|
|
||||||
def test_workflow_copy_warnings_jt(self, wfjt, rando, job_template):
|
def test_workflow_copy_warnings_jt(self, wfjt, rando, job_template):
|
||||||
wfjt.workflow_job_template_nodes.create(unified_job_template=job_template)
|
wfjt.workflow_job_template_nodes.create(unified_job_template=job_template)
|
||||||
access = WorkflowJobTemplateAccess(rando, save_messages=True)
|
access = WorkflowJobTemplateAccess(rando, save_messages=True)
|
||||||
assert not access.can_copy(wfjt)
|
assert not access.can_copy(wfjt)
|
||||||
warnings = access.messages
|
warnings = access.messages
|
||||||
assert 1 in warnings
|
assert 'templates_unable_to_copy' in warnings
|
||||||
assert 'unified_job_template' in warnings[1]
|
|
||||||
|
|||||||
@@ -239,14 +239,36 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest',
|
|||||||
</div>
|
</div>
|
||||||
<div class="Prompt-bodyTarget">`;
|
<div class="Prompt-bodyTarget">`;
|
||||||
|
|
||||||
// Go and grab all of the warning strings
|
// List the unified job templates user can not access
|
||||||
_.forOwn(result.data.templates_unable_to_copy, function(ujt) {
|
if (result.data.templates_unable_to_copy.length > 0) {
|
||||||
if(ujt) {
|
bodyHtml += '<div>Unified Job Templates that can not be copied<ul>';
|
||||||
// _.forOwn(ujts, function(warningString) {
|
_.forOwn(result.data.templates_unable_to_copy, function(ujt) {
|
||||||
bodyHtml += '<div>' + ujt + '</div>';
|
if(ujt) {
|
||||||
// });
|
bodyHtml += '<li>' + ujt + '</li>';
|
||||||
}
|
}
|
||||||
} );
|
});
|
||||||
|
bodyHtml += '</ul></div>';
|
||||||
|
}
|
||||||
|
// List the prompted inventories user can not access
|
||||||
|
if (result.data.inventories_unable_to_copy.length > 0) {
|
||||||
|
bodyHtml += '<div>Node prompted inventories that can not be copied<ul>';
|
||||||
|
_.forOwn(result.data.inventories_unable_to_copy, function(inv) {
|
||||||
|
if(inv) {
|
||||||
|
bodyHtml += '<li>' + inv + '</li>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bodyHtml += '</ul></div>';
|
||||||
|
}
|
||||||
|
// List the prompted credentials user can not access
|
||||||
|
if (result.data.credentials_unable_to_copy.length > 0) {
|
||||||
|
bodyHtml += '<div>Node prompted credentials that can not be copied<ul>';
|
||||||
|
_.forOwn(result.data.credentials_unable_to_copy, function(cred) {
|
||||||
|
if(cred) {
|
||||||
|
bodyHtml += '<li>' + cred + '</li>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bodyHtml += '</ul></div>';
|
||||||
|
}
|
||||||
|
|
||||||
bodyHtml += '</div>';
|
bodyHtml += '</div>';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user