mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 15:15:22 +00:00
define allow_admin_or_not_template variable, template cannot use parenthesis @honza801
This commit is contained in:
parent
5872700455
commit
605d24d699
2 changed files with 14 additions and 13 deletions
|
@ -72,7 +72,7 @@
|
||||||
{% trans "Resize" %}
|
{% trans "Resize" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% if request.user.is_superuser or request.user.is_staff or not userinstance.is_template %}
|
{% if allow_admin_or_not_template %}
|
||||||
<li role="presentation">
|
<li role="presentation">
|
||||||
<a href="#snapshots" class="action-button" aria-controls="snapshots" role="tab" data-toggle="tab">
|
<a href="#snapshots" class="action-button" aria-controls="snapshots" role="tab" data-toggle="tab">
|
||||||
<span id="action-block" class="glyphicon glyphicon-camera" aria-hidden="true"></span>
|
<span id="action-block" class="glyphicon glyphicon-camera" aria-hidden="true"></span>
|
||||||
|
@ -611,10 +611,10 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
{% if media_iso and request.user.is_superuser or request.user.is_staff or not userinstance.is_template %}
|
{% if media_iso and allow_admin_or_not_template %}
|
||||||
<button type="submit" class="btn btn-sm btn-success pull-left" name="mount_iso" value="{{ cd.dev }}" style="margin-top: 2px;">{% trans "Mount" %}</button>
|
<button type="submit" class="btn btn-sm btn-success pull-left" name="mount_iso" value="{{ cd.dev }}" style="margin-top: 2px;">{% trans "Mount" %}</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button class="btn btn-sm btn-success pull-left disabled" name="mount_iso" style="margin-top: 2px;">{% trans "Mount" %}</button>
|
<button class="btn btn-sm btn-success pull-left disabled" style="margin-top: 2px;">{% trans "Mount" %}</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -623,7 +623,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<input type="hidden" name="path" value="{{ cd.path }}">
|
<input type="hidden" name="path" value="{{ cd.path }}">
|
||||||
{% if request.user.is_superuser or request.user.is_staff or not userinstance.is_template %}
|
{% if allow_admin_or_not_template %}
|
||||||
<button type="submit" class="btn btn-sm btn-success pull-left" value="{{ cd.dev }}" name="umount_iso" style="margin-top: 2px;">{% trans "Umount" %}</button>
|
<button type="submit" class="btn btn-sm btn-success pull-left" value="{{ cd.dev }}" name="umount_iso" style="margin-top: 2px;">{% trans "Umount" %}</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button class="btn btn-sm btn-success pull-left disabled" value="{{ cd.dev }}" name="umount_iso" style="margin-top: 2px;">{% trans "Umount" %}</button>
|
<button class="btn btn-sm btn-success pull-left disabled" value="{{ cd.dev }}" name="umount_iso" style="margin-top: 2px;">{% trans "Umount" %}</button>
|
||||||
|
|
|
@ -310,6 +310,7 @@ def instance(request, compute_id, vname):
|
||||||
addlogmsg(request.user.username, instance.name, msg)
|
addlogmsg(request.user.username, instance.name, msg)
|
||||||
|
|
||||||
userinstances = UserInstance.objects.filter(instance=instance).order_by('user__username')
|
userinstances = UserInstance.objects.filter(instance=instance).order_by('user__username')
|
||||||
|
allow_admin_or_not_template = request.user.is_superuser or request.user.is_staff or not instance.is_template
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if 'poweron' in request.POST:
|
if 'poweron' in request.POST:
|
||||||
|
@ -444,7 +445,7 @@ 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() + '#resize')
|
return HttpResponseRedirect(request.get_full_path() + '#resize')
|
||||||
|
|
||||||
if 'addnewvol' in request.POST and (request.user.is_superuser or userinstance.is_change):
|
if 'addnewvol' in request.POST and allow_admin_or_not_template:
|
||||||
connCreate = wvmCreate(compute.hostname,
|
connCreate = wvmCreate(compute.hostname,
|
||||||
compute.login,
|
compute.login,
|
||||||
compute.password,
|
compute.password,
|
||||||
|
@ -464,7 +465,7 @@ 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() + '#disks')
|
return HttpResponseRedirect(request.get_full_path() + '#disks')
|
||||||
|
|
||||||
if 'addexistingvol' in request.POST and (request.user.is_superuser or userinstance.is_change):
|
if 'addexistingvol' in request.POST and allow_admin_or_not_template:
|
||||||
storage = request.POST.get('selected_storage', '')
|
storage = request.POST.get('selected_storage', '')
|
||||||
name = request.POST.get('vols', '')
|
name = request.POST.get('vols', '')
|
||||||
bus = request.POST.get('bus', default_bus)
|
bus = request.POST.get('bus', default_bus)
|
||||||
|
@ -486,7 +487,7 @@ 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() + '#disks')
|
return HttpResponseRedirect(request.get_full_path() + '#disks')
|
||||||
|
|
||||||
if 'delvolume' in request.POST and (request.user.is_superuser or userinstance.is_change):
|
if 'delvolume' in request.POST and allow_admin_or_not_template:
|
||||||
connDelete = wvmCreate(compute.hostname,
|
connDelete = wvmCreate(compute.hostname,
|
||||||
compute.login,
|
compute.login,
|
||||||
compute.password,
|
compute.password,
|
||||||
|
@ -501,7 +502,7 @@ 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() + '#disks')
|
return HttpResponseRedirect(request.get_full_path() + '#disks')
|
||||||
|
|
||||||
if 'detachvolume' in request.POST and (request.user.is_superuser or userinstance.is_change):
|
if 'detachvolume' in request.POST and allow_admin_or_not_template:
|
||||||
connDelete = wvmCreate(compute.hostname,
|
connDelete = wvmCreate(compute.hostname,
|
||||||
compute.login,
|
compute.login,
|
||||||
compute.password,
|
compute.password,
|
||||||
|
@ -513,7 +514,7 @@ 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() + '#disks')
|
return HttpResponseRedirect(request.get_full_path() + '#disks')
|
||||||
|
|
||||||
if 'umount_iso' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template):
|
if 'umount_iso' in request.POST and allow_admin_or_not_template:
|
||||||
image = request.POST.get('path', '')
|
image = request.POST.get('path', '')
|
||||||
dev = request.POST.get('umount_iso', '')
|
dev = request.POST.get('umount_iso', '')
|
||||||
conn.umount_iso(dev, image)
|
conn.umount_iso(dev, image)
|
||||||
|
@ -521,7 +522,7 @@ 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() + '#media')
|
return HttpResponseRedirect(request.get_full_path() + '#media')
|
||||||
|
|
||||||
if 'mount_iso' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template):
|
if 'mount_iso' in request.POST and allow_admin_or_not_template:
|
||||||
image = request.POST.get('media', '')
|
image = request.POST.get('media', '')
|
||||||
dev = request.POST.get('mount_iso', '')
|
dev = request.POST.get('mount_iso', '')
|
||||||
conn.mount_iso(dev, image)
|
conn.mount_iso(dev, image)
|
||||||
|
@ -529,21 +530,21 @@ 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() + '#media')
|
return HttpResponseRedirect(request.get_full_path() + '#media')
|
||||||
|
|
||||||
if 'snapshot' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template):
|
if 'snapshot' in request.POST and allow_admin_or_not_template:
|
||||||
name = request.POST.get('name', '')
|
name = request.POST.get('name', '')
|
||||||
conn.create_snapshot(name)
|
conn.create_snapshot(name)
|
||||||
msg = _("New snapshot")
|
msg = _("New snapshot")
|
||||||
addlogmsg(request.user.username, instance.name, msg)
|
addlogmsg(request.user.username, instance.name, msg)
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#managesnapshot')
|
return HttpResponseRedirect(request.get_full_path() + '#managesnapshot')
|
||||||
|
|
||||||
if 'delete_snapshot' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template):
|
if 'delete_snapshot' in request.POST and allow_admin_or_not_template:
|
||||||
snap_name = request.POST.get('name', '')
|
snap_name = request.POST.get('name', '')
|
||||||
conn.snapshot_delete(snap_name)
|
conn.snapshot_delete(snap_name)
|
||||||
msg = _("Delete snapshot")
|
msg = _("Delete snapshot")
|
||||||
addlogmsg(request.user.username, instance.name, msg)
|
addlogmsg(request.user.username, instance.name, msg)
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#managesnapshot')
|
return HttpResponseRedirect(request.get_full_path() + '#managesnapshot')
|
||||||
|
|
||||||
if 'revert_snapshot' in request.POST and (request.user.is_superuser or request.user.is_staff or not userinstance.is_template):
|
if 'revert_snapshot' in request.POST and allow_admin_or_not_template:
|
||||||
snap_name = request.POST.get('name', '')
|
snap_name = request.POST.get('name', '')
|
||||||
conn.snapshot_revert(snap_name)
|
conn.snapshot_revert(snap_name)
|
||||||
msg = _("Successful revert snapshot: ")
|
msg = _("Successful revert snapshot: ")
|
||||||
|
|
Loading…
Reference in a new issue