1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-23 22:55:23 +00:00

users with can_clone_instances ability are allowed to change_options of vm

This commit is contained in:
Ing. Jan KRCMAR 2017-10-26 15:51:10 +02:00
parent 96674221b4
commit 6d153a6acf
2 changed files with 23 additions and 15 deletions

View file

@ -620,11 +620,15 @@
{% trans "XML" %}
</a>
</li>
{% endif %}
{% if request.user.is_superuser or request.user.userattributes.can_clone_instances %}
<li role="presentation">
<a href="#options" aria-controls="options" role="tab" data-toggle="tab">
{% trans "Options" %}
</a>
</li>
{% endif %}
{% if request.user.is_superuser %}
<li role="presentation">
<a href="#users" aria-controls="users" role="tab" data-toggle="tab">
{% trans "Users" %}
@ -966,6 +970,8 @@
</form>
<div class="clearfix"></div>
</div>
{% endif %}
{% if request.user.is_superuser or request.user.userattributes.can_clone_instances %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="options">
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
<div class="form-group">
@ -983,7 +989,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Is template" %}</label>
<div class="col-sm-6">
<input type="checkbox" name="is_template" value="true" id="is_template" {% if instance.is_template %}checked{% endif %}>
<input type="checkbox" name="is_template" value="true" id="is_template" {% if instance.is_template %}checked{% endif %} {% if not request.user.is_superuser %}disabled{% endif %}>
</div>
</div>
{% ifequal status 5 %}
@ -994,6 +1000,8 @@
</form>
<div class="clearfix"></div>
</div>
{% endif %}
{% if request.user.is_superuser %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="users">
<div>
<p style="font-weight:bold;">

View file

@ -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: