mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
users with can_clone_instances ability are allowed to change_options of vm
This commit is contained in:
parent
96674221b4
commit
6d153a6acf
2 changed files with 23 additions and 15 deletions
|
@ -620,11 +620,15 @@
|
||||||
{% trans "XML" %}
|
{% trans "XML" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if request.user.is_superuser or request.user.userattributes.can_clone_instances %}
|
||||||
<li role="presentation">
|
<li role="presentation">
|
||||||
<a href="#options" aria-controls="options" role="tab" data-toggle="tab">
|
<a href="#options" aria-controls="options" role="tab" data-toggle="tab">
|
||||||
{% trans "Options" %}
|
{% trans "Options" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if request.user.is_superuser %}
|
||||||
<li role="presentation">
|
<li role="presentation">
|
||||||
<a href="#users" aria-controls="users" role="tab" data-toggle="tab">
|
<a href="#users" aria-controls="users" role="tab" data-toggle="tab">
|
||||||
{% trans "Users" %}
|
{% trans "Users" %}
|
||||||
|
@ -966,6 +970,8 @@
|
||||||
</form>
|
</form>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</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">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="options">
|
||||||
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
|
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -983,7 +989,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "Is template" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Is template" %}</label>
|
||||||
<div class="col-sm-6">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{% ifequal status 5 %}
|
{% ifequal status 5 %}
|
||||||
|
@ -994,6 +1000,8 @@
|
||||||
</form>
|
</form>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if request.user.is_superuser %}
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="users">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="users">
|
||||||
<div>
|
<div>
|
||||||
<p style="font-weight:bold;">
|
<p style="font-weight:bold;">
|
||||||
|
|
|
@ -651,20 +651,6 @@ def instance(request, compute_id, vname):
|
||||||
addlogmsg(request.user.username, instance.name, msg)
|
addlogmsg(request.user.username, instance.name, msg)
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#network')
|
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:
|
if 'add_owner' in request.POST:
|
||||||
user_id = int(request.POST.get('user_id', ''))
|
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)
|
addlogmsg(request.user.username, new_instance.name, msg)
|
||||||
return HttpResponseRedirect(reverse('instance', args=[compute_id, clone_data['name']]))
|
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()
|
conn.close()
|
||||||
|
|
||||||
except libvirtError as lib_err:
|
except libvirtError as lib_err:
|
||||||
|
|
Loading…
Reference in a new issue