mirror of
https://github.com/retspen/webvirtcloud
synced 2025-02-23 21:05:17 +00:00
Added permission can snapshot instances
This commit is contained in:
parent
e26a114c44
commit
052610dd21
3 changed files with 5 additions and 4 deletions
|
@ -216,6 +216,7 @@ class PermissionSet(models.Model):
|
||||||
('clone_instances', 'Can clone instances'),
|
('clone_instances', 'Can clone instances'),
|
||||||
('passwordless_console', _('Can access console without password')),
|
('passwordless_console', _('Can access console without password')),
|
||||||
('view_instances', 'Can view instances'),
|
('view_instances', 'Can view instances'),
|
||||||
|
('snapshot_instances', 'Can snapshot instances'),
|
||||||
]
|
]
|
||||||
|
|
||||||
managed = False
|
managed = False
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
{% trans "Resize" %}
|
{% trans "Resize" %}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
{% if allow_admin_or_not_template %}
|
{% if allow_admin_or_not_template and 'instances.snapshot_instances' in perms %}
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link action-button" id="snapshots-tab" aria-controls="snapshots" data-bs-toggle="pill" data-bs-target="#snapshots" type="button" role="tab" aria-selected="false">
|
<button class="nav-link action-button" id="snapshots-tab" aria-controls="snapshots" data-bs-toggle="pill" data-bs-target="#snapshots" type="button" role="tab" aria-selected="false">
|
||||||
<span id="action-block" class="fa fa-camera" aria-hidden="true"></span>
|
<span id="action-block" class="fa fa-camera" aria-hidden="true"></span>
|
||||||
|
|
|
@ -813,7 +813,7 @@ def snapshot(request, pk):
|
||||||
instance = get_instance(request.user, pk)
|
instance = get_instance(request.user, pk)
|
||||||
allow_admin_or_not_template = request.user.is_superuser or request.user.is_staff or not instance.is_template
|
allow_admin_or_not_template = request.user.is_superuser or request.user.is_staff or not instance.is_template
|
||||||
|
|
||||||
if allow_admin_or_not_template:
|
if allow_admin_or_not_template and request.user.has_perm("instances.snapshot_instances"):
|
||||||
name = request.POST.get("name", "")
|
name = request.POST.get("name", "")
|
||||||
instance.proxy.create_snapshot(name)
|
instance.proxy.create_snapshot(name)
|
||||||
msg = _("Create snapshot: %(snap)s") % {"snap": name}
|
msg = _("Create snapshot: %(snap)s") % {"snap": name}
|
||||||
|
@ -824,7 +824,7 @@ def snapshot(request, pk):
|
||||||
def delete_snapshot(request, pk):
|
def delete_snapshot(request, pk):
|
||||||
instance = get_instance(request.user, pk)
|
instance = get_instance(request.user, pk)
|
||||||
allow_admin_or_not_template = request.user.is_superuser or request.user.is_staff or not instance.is_template
|
allow_admin_or_not_template = request.user.is_superuser or request.user.is_staff or not instance.is_template
|
||||||
if allow_admin_or_not_template:
|
if allow_admin_or_not_template and request.user.has_perm("instances.snapshot_instances"):
|
||||||
snap_name = request.POST.get("name", "")
|
snap_name = request.POST.get("name", "")
|
||||||
instance.proxy.snapshot_delete(snap_name)
|
instance.proxy.snapshot_delete(snap_name)
|
||||||
msg = _("Delete snapshot: %(snap)s") % {"snap": snap_name}
|
msg = _("Delete snapshot: %(snap)s") % {"snap": snap_name}
|
||||||
|
@ -835,7 +835,7 @@ def delete_snapshot(request, pk):
|
||||||
def revert_snapshot(request, pk):
|
def revert_snapshot(request, pk):
|
||||||
instance = get_instance(request.user, pk)
|
instance = get_instance(request.user, pk)
|
||||||
allow_admin_or_not_template = request.user.is_superuser or request.user.is_staff or not instance.is_template
|
allow_admin_or_not_template = request.user.is_superuser or request.user.is_staff or not instance.is_template
|
||||||
if allow_admin_or_not_template:
|
if allow_admin_or_not_template and request.user.has_perm("instances.snapshot_instances"):
|
||||||
snap_name = request.POST.get("name", "")
|
snap_name = request.POST.get("name", "")
|
||||||
instance.proxy.snapshot_revert(snap_name)
|
instance.proxy.snapshot_revert(snap_name)
|
||||||
msg = _("Successful revert snapshot: ")
|
msg = _("Successful revert snapshot: ")
|
||||||
|
|
Loading…
Reference in a new issue