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

Little fix user page

This commit is contained in:
Retspen 2015-03-16 15:46:44 +02:00
parent 983dbaf91a
commit 5ba82e29aa
7 changed files with 313 additions and 286 deletions

View file

@ -5,4 +5,17 @@ from logs.models import Logs
def showlogs(request): def showlogs(request):
"""
:param request:
:return:
"""
if not request.user.is_authenticated():
return HttpResponseRedirect(reverse('index'))
if not request.user.is_superuser:
return HttpResponseRedirect(reverse('index'))
return render(request, 'showlogs.html', locals()) return render(request, 'showlogs.html', locals())

View file

@ -97,7 +97,7 @@
{% trans "Power Off" %} {% trans "Power Off" %}
</a> </a>
</li> </li>
{% if status %} {% if request.user.is_superuser %}
<li role="presentation"> <li role="presentation">
<a href="#suspend" aria-controls="suspend" role="tab" data-toggle="tab"> <a href="#suspend" aria-controls="suspend" role="tab" data-toggle="tab">
{% trans "Suspend" %} {% trans "Suspend" %}
@ -105,6 +105,7 @@
</li> </li>
{% endif %} {% endif %}
{% endifequal %} {% endifequal %}
{% if request.user.is_superuser %}
{% ifequal status 3 %} {% ifequal status 3 %}
<li role="presentation" class="active"> <li role="presentation" class="active">
<a href="#resume" aria-controls="resume" role="tab" data-toggle="tab"> <a href="#resume" aria-controls="resume" role="tab" data-toggle="tab">
@ -112,6 +113,7 @@
</a> </a>
</li> </li>
{% endifequal %} {% endifequal %}
{% endif %}
{% ifequal status 5 %} {% ifequal status 5 %}
<li role="presentation" class="active"> <li role="presentation" class="active">
<a href="#boot" aria-controls="boot" role="tab" data-toggle="tab"> <a href="#boot" aria-controls="boot" role="tab" data-toggle="tab">
@ -137,6 +139,7 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</form> </form>
</div> </div>
{% if request.user.is_superuser %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="suspend"> <div role="tabpanel" class="tab-pane tab-pane-bordered" id="suspend">
<p>{% trans "This action suspends the instance." %}</p> <p>{% trans "This action suspends the instance." %}</p>
<form action="" method="post" role="form">{% csrf_token %} <form action="" method="post" role="form">{% csrf_token %}
@ -144,7 +147,9 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</form> </form>
</div> </div>
{% endif %}
{% endifequal %} {% endifequal %}
{% if request.user.is_superuser %}
{% ifequal status 3 %} {% ifequal status 3 %}
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume">
<p>{% trans "This action restore the instance after suspend." %}</p> <p>{% trans "This action restore the instance after suspend." %}</p>
@ -154,6 +159,7 @@
</form> </form>
</div> </div>
{% endifequal %} {% endifequal %}
{% endif %}
{% ifequal status 5 %} {% ifequal status 5 %}
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot"> <div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot">
<p>{% trans "Click on Boot button to start this instance." %}</p> <p>{% trans "Click on Boot button to start this instance." %}</p>
@ -375,6 +381,7 @@
{% trans "Media" %} {% trans "Media" %}
</a> </a>
</li> </li>
{% if request.user.is_superuser %}
<li role="presentation"> <li role="presentation">
<a href="#autostart" aria-controls="autostart" role="tab" data-toggle="tab"> <a href="#autostart" aria-controls="autostart" role="tab" data-toggle="tab">
{% trans "Autostart" %} {% trans "Autostart" %}
@ -400,6 +407,7 @@
{% trans "XML" %} {% trans "XML" %}
</a> </a>
</li> </li>
{% endif %}
</ul> </ul>
<!-- Tab panes --> <!-- Tab panes -->
<div class="tab-content"> <div class="tab-content">
@ -441,6 +449,7 @@
</form> </form>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
{% if request.user.is_superuser %}
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="autostart"> <div role="tabpanel" class="tab-pane tab-pane-bordered" id="autostart">
<p>{% trans "Autostart your instance when host server is power on" %}</p> <p>{% trans "Autostart your instance when host server is power on" %}</p>
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %} <form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
@ -657,6 +666,7 @@
</form> </form>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>

View file

@ -28,10 +28,9 @@
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
<th>{% trans "Name" %}</th> <th>{% trans "Instance" %}</th>
<th>{% trans "User blocked" %}</th> <th>{% trans "Resize" %}</th>
<th>{% trans "Can change" %}</th> <th>{% trans "Delete" %}</th>
<th>{% trans "Can delete" %}</th>
<th colspan="2">{% trans "Action" %}</th> <th colspan="2">{% trans "Action" %}</th>
</tr> </tr>
</thead> </thead>
@ -39,8 +38,7 @@
{% for inst in user_insts %} {% for inst in user_insts %}
<tr> <tr>
<td>{{ forloop.counter }}</td> <td>{{ forloop.counter }}</td>
<td>{{ inst.instance.name }}</td> <td><a href="{% url 'instance' inst.instance.compute.id inst.instance.name %}">{{ inst.instance.name }}</a></td>
<td>{{ inst.is_block }}</td>
<td>{{ inst.is_change }}</td> <td>{{ inst.is_change }}</td>
<td>{{ inst.is_delete }}</td> <td>{{ inst.is_delete }}</td>
<td style="width:5px;"> <td style="width:5px;">
@ -58,38 +56,29 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form class="form-horizontal" method="post" action="" role="form">{% csrf_token %} <form class="form-horizontal" method="post" action="" role="form">{% csrf_token %}
<div class="form-group">
<label class="col-sm-4 control-label">{% trans "Is blocked" %}</label>
<div class="col-sm-6">
<input type="hidden" name="user_inst" value="{{ inst.id }}"> <input type="hidden" name="user_inst" value="{{ inst.id }}">
<select type="text" class="form-control" name="inst_block">
<option value="">False</option>
<option value="1">True</option>
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label">{% trans "Can change" %}</label> <label class="col-sm-4 control-label">{% trans "Resize" %}</label>
<div class="col-sm-6"> <div class="col-sm-6">
<select type="text" class="form-control" name="inst_change"> <select type="text" class="form-control" name="inst_change">
<option value="">False</option> <option value="">False</option>
<option value="1">True</option> <option value="1" {% if inst.is_change %}selected{% endif %}>True</option>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label">{% trans "Can delete" %}</label> <label class="col-sm-4 control-label">{% trans "Delete" %}</label>
<div class="col-sm-6"> <div class="col-sm-6">
<select type="text" class="form-control" name="inst_delete"> <select type="text" class="form-control" name="inst_delete">
<option value="">False</option> <option value="">False</option>
<option value="1">True</option> <option value="1" {% if inst.is_delete %}selected{% endif %}>True</option>
</select> </select>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button> <button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
<button type="submit" class="btn btn-primary" name="edit">{% trans "Edit" %}</button> <button type="submit" class="btn btn-primary" name="permission">{% trans "Edit" %}</button>
</div> </div>
</form> </form>
</div> <!-- /.modal-content --> </div> <!-- /.modal-content -->

View file

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('users', '0002_userinstance_is_block'),
]
operations = [
migrations.RemoveField(
model_name='userinstance',
name='is_block',
),
]

View file

@ -8,7 +8,6 @@ class UserInstance(models.Model):
instance = models.ForeignKey(Instance) instance = models.ForeignKey(Instance)
is_change = models.BooleanField(default=False) is_change = models.BooleanField(default=False)
is_delete = models.BooleanField(default=False) is_delete = models.BooleanField(default=False)
is_block = models.BooleanField(default=False)
def __unicode__(self): def __unicode__(self):
return self.instance.name return self.instance.name

View file

@ -90,13 +90,11 @@ def user(request, user_id):
del_user_inst = UserInstance.objects.get(id=user_inst) del_user_inst = UserInstance.objects.get(id=user_inst)
del_user_inst.delete() del_user_inst.delete()
return HttpResponseRedirect(request.get_full_path()) return HttpResponseRedirect(request.get_full_path())
if 'edit' in request.POST: if 'permission' in request.POST:
user_inst = request.POST.get('user_inst', '') user_inst = request.POST.get('user_inst', '')
inst_block = request.POST.get('inst_block', '')
inst_change = request.POST.get('inst_change', '') inst_change = request.POST.get('inst_change', '')
inst_delete = request.POST.get('inst_delete', '') inst_delete = request.POST.get('inst_delete', '')
edit_user_inst = UserInstance.objects.get(id=user_inst) edit_user_inst = UserInstance.objects.get(id=user_inst)
edit_user_inst.is_block = bool(inst_block)
edit_user_inst.is_change = bool(inst_change) edit_user_inst.is_change = bool(inst_change)
edit_user_inst.is_delete = bool(inst_delete) edit_user_inst.is_delete = bool(inst_delete)
edit_user_inst.save() edit_user_inst.save()

View file

@ -22,7 +22,7 @@ urlpatterns = patterns('',
url(r'^compute/net/(\d+)/([\w\-\.]+)/$', 'networks.views.network', name='network'), url(r'^compute/net/(\d+)/([\w\-\.]+)/$', 'networks.views.network', name='network'),
url(r'^compute/ifaces/(\d+)/$', 'interfaces.views.interfaces', name='interfaces'), url(r'^compute/ifaces/(\d+)/$', 'interfaces.views.interfaces', name='interfaces'),
url(r'^compute/iface/(\d+)/([\w\.]+)$', 'interfaces.views.interface', name='interface'), url(r'^compute/iface/(\d+)/([\w\.\:]+)$', 'interfaces.views.interface', name='interface'),
url(r'^compute/secret/(\d+)/$', 'secrets.views.secrets', name='secrets'), url(r'^compute/secret/(\d+)/$', 'secrets.views.secrets', name='secrets'),