diff --git a/instances/templates/instance.html b/instances/templates/instance.html index 8747807..6107285 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -72,12 +72,14 @@ {% trans "Resize" %} -
  • - - - {% trans "Snapshots" %} - -
  • + {% if request.user.is_superuser or request.user.is_staff or not userinstance.is_template %} +
  • + + + {% trans "Snapshots" %} + +
  • + {% endif %}
  • @@ -609,7 +611,7 @@
    - {% if media_iso %} + {% if media_iso and request.user.is_superuser or request.user.is_staff or not userinstance.is_template %} {% else %} @@ -621,7 +623,11 @@
    - + {% if request.user.is_superuser or request.user.is_staff or not userinstance.is_template %} + + {% else %} + + {% endif %}
    {% endif %} diff --git a/instances/views.py b/instances/views.py index aff0e78..e81c35d 100644 --- a/instances/views.py +++ b/instances/views.py @@ -507,7 +507,7 @@ def instance(request, compute_id, vname): addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path() + '#disks') - if 'umount_iso' in request.POST: + if 'umount_iso' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template): image = request.POST.get('path', '') dev = request.POST.get('umount_iso', '') conn.umount_iso(dev, image) @@ -515,7 +515,7 @@ def instance(request, compute_id, vname): addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path() + '#media') - if 'mount_iso' in request.POST: + if 'mount_iso' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template): image = request.POST.get('media', '') dev = request.POST.get('mount_iso', '') conn.mount_iso(dev, image) @@ -523,21 +523,21 @@ def instance(request, compute_id, vname): addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path() + '#media') - if 'snapshot' in request.POST: + if 'snapshot' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template): name = request.POST.get('name', '') conn.create_snapshot(name) msg = _("New snapshot") addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path() + '#managesnapshot') - if 'delete_snapshot' in request.POST: + if 'delete_snapshot' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template): snap_name = request.POST.get('name', '') conn.snapshot_delete(snap_name) msg = _("Delete snapshot") addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path() + '#managesnapshot') - if 'revert_snapshot' in request.POST: + if 'revert_snapshot' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template): snap_name = request.POST.get('name', '') conn.snapshot_revert(snap_name) msg = _("Successful revert snapshot: ") @@ -761,7 +761,7 @@ def instance(request, compute_id, vname): return HttpResponseRedirect( reverse('instance', args=[new_instance.compute.id, new_instance.name])) - if 'change_options' in request.POST: + if 'change_options' in request.POST and (request.user.is_superuser or request.user.is_staff or userinstance.is_change): instance.is_template = request.POST.get('is_template', False) instance.save()