You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2019/07/09 07:12:54 UTC
[cloudstack] branch master updated: api: Allowing template owner to
download template (#3475)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new b509e08 api: Allowing template owner to download template (#3475)
b509e08 is described below
commit b509e086f99141de6ff588ceaa5d6d3cd0648eca
Author: Spaceman1984 <49...@users.noreply.github.com>
AuthorDate: Tue Jul 9 09:12:41 2019 +0200
api: Allowing template owner to download template (#3475)
Removed the download icon when a template is not extractable.
Modified the api to allow a user from the same account as the template, to change the extractable attribute on the template.
Fixes #3400
---
.../com/cloud/template/TemplateManagerImpl.java | 6 +++---
ui/scripts/templates.js | 25 ++++++----------------
2 files changed, 9 insertions(+), 22 deletions(-)
diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
index 5eb96aa..373735c 100755
--- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
@@ -1523,9 +1523,9 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
}
if (isExtractable != null) {
- // Only Root admins allowed to change it for templates
- if (!template.getFormat().equals(ImageFormat.ISO) && !_accountMgr.isRootAdmin(caller.getId())) {
- throw new InvalidParameterValueException("Only ROOT admins are allowed to modify isExtractable attribute.");
+ // Only Root admins and owners are allowed to change it for templates
+ if (!template.getFormat().equals(ImageFormat.ISO) && caller.getId() != ownerId && !isAdmin) {
+ throw new InvalidParameterValueException("Only ROOT admins and template owners are allowed to modify isExtractable attribute.");
} else {
// For Isos normal user can change it, as their are no derivatives.
updatedTemplate.setExtractable(isExtractable.booleanValue());
diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js
index df04000..c64efc9 100755
--- a/ui/scripts/templates.js
+++ b/ui/scripts/templates.js
@@ -1595,12 +1595,7 @@
isextractable: {
label: 'label.extractable.lower',
isBoolean: true,
- isEditable: function() {
- if (isAdmin())
- return true;
- else
- return false;
- },
+ isEditable: true,
converter: cloudStack.converters.toBooleanText
},
passwordenabled: {
@@ -2039,12 +2034,7 @@
isextractable: {
label: 'label.extractable.lower',
isBoolean: true,
- isEditable: function() {
- if (isAdmin())
- return true;
- else
- return false;
- },
+ isEditable: true,
converter: cloudStack.converters.toBooleanText
},
passwordenabled: {
@@ -3327,12 +3317,7 @@
isextractable: {
label: 'label.extractable.lower',
isBoolean: true,
- isEditable: function() {
- if (isAdmin())
- return true;
- else
- return false;
- },
+ isEditable: true,
converter: cloudStack.converters.toBooleanText
},
bootable: {
@@ -3449,7 +3434,9 @@
|| (jsonObj.isready == false) || jsonObj.templatetype == "SYSTEM") {
//do nothing
} else {
- allowedActions.push("downloadTemplate");
+ if (jsonObj.isextractable){
+ allowedActions.push("downloadTemplate");
+ }
}
// "Delete Template"