From 6d153a6acfe9f04af2f4e14dbfabb3efa4b742aa Mon Sep 17 00:00:00 2001 From: "Ing. Jan KRCMAR" Date: Thu, 26 Oct 2017 15:51:10 +0200 Subject: [PATCH] users with can_clone_instances ability are allowed to change_options of vm --- instances/templates/instance.html | 10 +++++++++- instances/views.py | 28 ++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/instances/templates/instance.html b/instances/templates/instance.html index 39e9b7e..1579da2 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -620,11 +620,15 @@ {% trans "XML" %} + {% endif %} + {% if request.user.is_superuser or request.user.userattributes.can_clone_instances %}
  • {% trans "Options" %}
  • + {% endif %} + {% if request.user.is_superuser %}
  • {% trans "Users" %} @@ -966,6 +970,8 @@
    + {% endif %} + {% if request.user.is_superuser or request.user.userattributes.can_clone_instances %}
    {% csrf_token %}
    @@ -983,7 +989,7 @@
    - +
    {% ifequal status 5 %} @@ -994,6 +1000,8 @@
    + {% endif %} + {% if request.user.is_superuser %}

    diff --git a/instances/views.py b/instances/views.py index 45b661a..b31e5ea 100644 --- a/instances/views.py +++ b/instances/views.py @@ -651,20 +651,6 @@ def instance(request, compute_id, vname): addlogmsg(request.user.username, instance.name, msg) return HttpResponseRedirect(request.get_full_path() + '#network') - if 'change_options' in request.POST: - instance.is_template = request.POST.get('is_template', False) - instance.save() - - options = {} - for post in request.POST: - if post in ['title', 'description']: - options[post] = request.POST.get(post, '') - conn.set_options(options) - - msg = _("Edit options") - addlogmsg(request.user.username, instance.name, msg) - return HttpResponseRedirect(request.get_full_path() + '#options') - if 'add_owner' in request.POST: user_id = int(request.POST.get('user_id', '')) @@ -727,6 +713,20 @@ def instance(request, compute_id, vname): addlogmsg(request.user.username, new_instance.name, msg) return HttpResponseRedirect(reverse('instance', args=[compute_id, clone_data['name']])) + if 'change_options' in request.POST: + instance.is_template = request.POST.get('is_template', False) + instance.save() + + options = {} + for post in request.POST: + if post in ['title', 'description']: + options[post] = request.POST.get(post, '') + conn.set_options(options) + + msg = _("Edit options") + addlogmsg(request.user.username, instance.name, msg) + return HttpResponseRedirect(request.get_full_path() + '#options') + conn.close() except libvirtError as lib_err: