Skip to content

Commit b509e08

Browse files
Spaceman1984yadvr
authored andcommitted
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
1 parent c88540d commit b509e08

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

server/src/main/java/com/cloud/template/TemplateManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,9 +1523,9 @@ public boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissions
15231523
}
15241524

15251525
if (isExtractable != null) {
1526-
// Only Root admins allowed to change it for templates
1527-
if (!template.getFormat().equals(ImageFormat.ISO) && !_accountMgr.isRootAdmin(caller.getId())) {
1528-
throw new InvalidParameterValueException("Only ROOT admins are allowed to modify isExtractable attribute.");
1526+
// Only Root admins and owners are allowed to change it for templates
1527+
if (!template.getFormat().equals(ImageFormat.ISO) && caller.getId() != ownerId && !isAdmin) {
1528+
throw new InvalidParameterValueException("Only ROOT admins and template owners are allowed to modify isExtractable attribute.");
15291529
} else {
15301530
// For Isos normal user can change it, as their are no derivatives.
15311531
updatedTemplate.setExtractable(isExtractable.booleanValue());

ui/scripts/templates.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,12 +1595,7 @@
15951595
isextractable: {
15961596
label: 'label.extractable.lower',
15971597
isBoolean: true,
1598-
isEditable: function() {
1599-
if (isAdmin())
1600-
return true;
1601-
else
1602-
return false;
1603-
},
1598+
isEditable: true,
16041599
converter: cloudStack.converters.toBooleanText
16051600
},
16061601
passwordenabled: {
@@ -2039,12 +2034,7 @@
20392034
isextractable: {
20402035
label: 'label.extractable.lower',
20412036
isBoolean: true,
2042-
isEditable: function() {
2043-
if (isAdmin())
2044-
return true;
2045-
else
2046-
return false;
2047-
},
2037+
isEditable: true,
20482038
converter: cloudStack.converters.toBooleanText
20492039
},
20502040
passwordenabled: {
@@ -3327,12 +3317,7 @@
33273317
isextractable: {
33283318
label: 'label.extractable.lower',
33293319
isBoolean: true,
3330-
isEditable: function() {
3331-
if (isAdmin())
3332-
return true;
3333-
else
3334-
return false;
3335-
},
3320+
isEditable: true,
33363321
converter: cloudStack.converters.toBooleanText
33373322
},
33383323
bootable: {
@@ -3449,7 +3434,9 @@
34493434
|| (jsonObj.isready == false) || jsonObj.templatetype == "SYSTEM") {
34503435
//do nothing
34513436
} else {
3452-
allowedActions.push("downloadTemplate");
3437+
if (jsonObj.isextractable){
3438+
allowedActions.push("downloadTemplate");
3439+
}
34533440
}
34543441

34553442
// "Delete Template"

0 commit comments

Comments
 (0)