1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-10-31 19:44:16 +00:00

Added users page

This commit is contained in:
Retspen 2015-03-02 10:52:07 +02:00
parent 0c63e00711
commit 29b05745ad
16 changed files with 112 additions and 16 deletions

View file

@ -1,6 +0,0 @@
from django.shortcuts import render
from django.contrib.auth.models import User
def accounts(request):
return

View file

@ -11,7 +11,7 @@ from vrtManager import util
from libvirt import libvirtError
def create_instance(request, host_id):
def create_instance(request, compute_id):
"""
:param request:
:return:
@ -25,7 +25,7 @@ def create_instance(request, host_id):
storages = []
networks = []
meta_prealloc = False
compute = Compute.objects.get(id=host_id)
compute = Compute.objects.get(id=compute_id)
flavors = Flavor.objects.filter().order_by('id')
try:
@ -78,7 +78,7 @@ def create_instance(request, host_id):
else:
try:
conn._defineXML(xml)
return HttpResponseRedirect(reverse('instance', args=[host_id, name]))
return HttpResponseRedirect(reverse('instance', args=[compute_id, name]))
except libvirtError as lib_err:
error_messages.append(lib_err.message)
if 'create' in request.POST:
@ -133,4 +133,4 @@ def create_instance(request, host_id):
error_messages.append(lib_err)
conn.close()
return render('create.html', locals())
return render(request, 'create_instance.html', locals())

View file

@ -0,0 +1,20 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Compute" %}{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row">
{% include 'sidebar.html' %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<button type="button" class="btn btn-success pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<h1 class="page-header">{{ compute.name }}</h1>
{% include 'errors.html' %}
</div>
</div>
</div>
{% endblock %}

View file

@ -6,7 +6,7 @@
<ul class="nav nav-sidebar">
<li {% active request "^/instance" %}><a href="{% url 'instances' %}"><span class="glyphicon glyphicon-th" aria-hidden="true"></span></a></li>
<li {% active request "^/compute" %}><a href="{% url 'computes' %}"><span class="glyphicon glyphicon-tasks" aria-hidden="true"></span></a></li>
<li {% active request "^/accaunt" %}><a href="#"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a></li>
<li {% active request "^/user" %}><a href="{% url 'users' %}"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a></li>
<li class="bottom-sticky">
<a href="#"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span></a>
<a href="{% url 'logout' %}"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span></a>

21
templates/user.html Normal file
View file

@ -0,0 +1,21 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Accounts" %}{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row">
{% include 'sidebar.html' %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<button type="button" class="btn btn-success pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<h1 class="page-header">{{ user.username }}</h1>
{% include 'errors.html' %}
{{ user }}
</div>
</div>
</div>
{% endblock %}

38
templates/users.html Normal file
View file

@ -0,0 +1,38 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Users" %}{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row">
{% include 'sidebar.html' %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<button type="button" class="btn btn-success pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<h1 class="page-header">{% trans "Accounts" %}</h1>
{% include 'errors.html' %}
{% for user in users %}
<div id="{{ user.username }}" class="col-xs-6 col-sm-4">
<div class="panel {% if user.is_active %}panel-success{% else %}panel-danger{% endif %} panel-data">
<div class="panel-heading">
<h3 class="panel-title"><strong>{{ user.username }}</strong>
<a data-toggle="modal" href="{% url 'user' user.id %}" class="pull-right"
title="{% trans "Edit" %}">
<span class="glyphicon glyphicon-cog"></span>
</a>
</h3>
</div>
<div class="panel-body">
<p>Status: {% if user.is_active %}Active{% else %}Blocked{% endif %}
</p>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endblock %}

View file

@ -7,7 +7,7 @@ from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('accounts', '0001_initial'),
('users', '0001_initial'),
]
operations = [

23
users/views.py Normal file
View file

@ -0,0 +1,23 @@
from django.shortcuts import render
from django.contrib.auth.models import User
def users(request):
"""
:param request:
:return:
"""
users = User.objects.filter(is_staff=False, is_superuser=False)
return render(request, 'users.html', locals())
def user(request, user_id):
"""
:param request:
:return:
"""
user = User.objects.get(id=user_id)
return render(request, 'user.html', locals())

View file

@ -23,7 +23,7 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'computes',
'instances',
'accounts',
'users',
'create',
)

View file

@ -26,9 +26,9 @@ urlpatterns = patterns('',
url(r'^secret/(\d+)/$', 'secrets.views.secrets', name='secrets'),
# url(r'^accounts/$', 'accounts.views.accounts', name='accounts'),
# url(r'^account/(\d+)/$', 'accounts.views.account', name='account'),
#
url(r'^users/$', 'users.views.users', name='users'),
url(r'^user/(\d+)/$', 'users.views.user', name='user'),
url(r'^console/$', 'console.views.console', name='console'),
url(r'^create/(\d+)/$', 'create.views.create_instance', name='create_instance'),
(r'^admin/', include(admin.site.urls)),