mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 15:15:22 +00:00
Little fix user page
This commit is contained in:
parent
983dbaf91a
commit
5ba82e29aa
7 changed files with 313 additions and 286 deletions
|
@ -5,4 +5,17 @@ from logs.models import Logs
|
|||
|
||||
|
||||
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())
|
|
@ -97,7 +97,7 @@
|
|||
{% trans "Power Off" %}
|
||||
</a>
|
||||
</li>
|
||||
{% if status %}
|
||||
{% if request.user.is_superuser %}
|
||||
<li role="presentation">
|
||||
<a href="#suspend" aria-controls="suspend" role="tab" data-toggle="tab">
|
||||
{% trans "Suspend" %}
|
||||
|
@ -105,6 +105,7 @@
|
|||
</li>
|
||||
{% endif %}
|
||||
{% endifequal %}
|
||||
{% if request.user.is_superuser %}
|
||||
{% ifequal status 3 %}
|
||||
<li role="presentation" class="active">
|
||||
<a href="#resume" aria-controls="resume" role="tab" data-toggle="tab">
|
||||
|
@ -112,6 +113,7 @@
|
|||
</a>
|
||||
</li>
|
||||
{% endifequal %}
|
||||
{% endif %}
|
||||
{% ifequal status 5 %}
|
||||
<li role="presentation" class="active">
|
||||
<a href="#boot" aria-controls="boot" role="tab" data-toggle="tab">
|
||||
|
@ -137,6 +139,7 @@
|
|||
<div class="clearfix"></div>
|
||||
</form>
|
||||
</div>
|
||||
{% if request.user.is_superuser %}
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="suspend">
|
||||
<p>{% trans "This action suspends the instance." %}</p>
|
||||
<form action="" method="post" role="form">{% csrf_token %}
|
||||
|
@ -144,7 +147,9 @@
|
|||
<div class="clearfix"></div>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endifequal %}
|
||||
{% if request.user.is_superuser %}
|
||||
{% ifequal status 3 %}
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resume">
|
||||
<p>{% trans "This action restore the instance after suspend." %}</p>
|
||||
|
@ -154,6 +159,7 @@
|
|||
</form>
|
||||
</div>
|
||||
{% endifequal %}
|
||||
{% endif %}
|
||||
{% ifequal status 5 %}
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot">
|
||||
<p>{% trans "Click on Boot button to start this instance." %}</p>
|
||||
|
@ -375,6 +381,7 @@
|
|||
{% trans "Media" %}
|
||||
</a>
|
||||
</li>
|
||||
{% if request.user.is_superuser %}
|
||||
<li role="presentation">
|
||||
<a href="#autostart" aria-controls="autostart" role="tab" data-toggle="tab">
|
||||
{% trans "Autostart" %}
|
||||
|
@ -400,6 +407,7 @@
|
|||
{% trans "XML" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
|
@ -441,6 +449,7 @@
|
|||
</form>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{% if request.user.is_superuser %}
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="autostart">
|
||||
<p>{% trans "Autostart your instance when host server is power on" %}</p>
|
||||
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
|
||||
|
@ -657,6 +666,7 @@
|
|||
</form>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -28,10 +28,9 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>{% trans "Name" %}</th>
|
||||
<th>{% trans "User blocked" %}</th>
|
||||
<th>{% trans "Can change" %}</th>
|
||||
<th>{% trans "Can delete" %}</th>
|
||||
<th>{% trans "Instance" %}</th>
|
||||
<th>{% trans "Resize" %}</th>
|
||||
<th>{% trans "Delete" %}</th>
|
||||
<th colspan="2">{% trans "Action" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -39,8 +38,7 @@
|
|||
{% for inst in user_insts %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ inst.instance.name }}</td>
|
||||
<td>{{ inst.is_block }}</td>
|
||||
<td><a href="{% url 'instance' inst.instance.compute.id inst.instance.name %}">{{ inst.instance.name }}</a></td>
|
||||
<td>{{ inst.is_change }}</td>
|
||||
<td>{{ inst.is_delete }}</td>
|
||||
<td style="width:5px;">
|
||||
|
@ -58,38 +56,29 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<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 }}">
|
||||
<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">
|
||||
<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">
|
||||
<select type="text" class="form-control" name="inst_change">
|
||||
<option value="">False</option>
|
||||
<option value="1">True</option>
|
||||
<option value="1" {% if inst.is_change %}selected{% endif %}>True</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<select type="text" class="form-control" name="inst_delete">
|
||||
<option value="">False</option>
|
||||
<option value="1">True</option>
|
||||
<option value="1" {% if inst.is_delete %}selected{% endif %}>True</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<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>
|
||||
</form>
|
||||
</div> <!-- /.modal-content -->
|
||||
|
|
18
users/migrations/0003_remove_userinstance_is_block.py
Normal file
18
users/migrations/0003_remove_userinstance_is_block.py
Normal 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',
|
||||
),
|
||||
]
|
|
@ -8,7 +8,6 @@ class UserInstance(models.Model):
|
|||
instance = models.ForeignKey(Instance)
|
||||
is_change = models.BooleanField(default=False)
|
||||
is_delete = models.BooleanField(default=False)
|
||||
is_block = models.BooleanField(default=False)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.instance.name
|
|
@ -90,13 +90,11 @@ def user(request, user_id):
|
|||
del_user_inst = UserInstance.objects.get(id=user_inst)
|
||||
del_user_inst.delete()
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
if 'edit' in request.POST:
|
||||
if 'permission' in request.POST:
|
||||
user_inst = request.POST.get('user_inst', '')
|
||||
inst_block = request.POST.get('inst_block', '')
|
||||
inst_change = request.POST.get('inst_change', '')
|
||||
inst_delete = request.POST.get('inst_delete', '')
|
||||
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_delete = bool(inst_delete)
|
||||
edit_user_inst.save()
|
||||
|
|
|
@ -22,7 +22,7 @@ urlpatterns = patterns('',
|
|||
url(r'^compute/net/(\d+)/([\w\-\.]+)/$', 'networks.views.network', name='network'),
|
||||
|
||||
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'),
|
||||
|
||||
|
|
Loading…
Reference in a new issue