From 02ae7336eac3734ef9e91f66313b4fa389c745ae Mon Sep 17 00:00:00 2001 From: Retspen Date: Wed, 18 Mar 2015 17:13:44 +0200 Subject: [PATCH] Refactor users page --- {users => accounts}/__init__.py | 0 {users => accounts}/admin.py | 0 {users => accounts}/forms.py | 0 .../migrations/0001_initial.py | 0 .../migrations/0002_userinstance_is_block.py | 2 +- .../0003_remove_userinstance_is_block.py | 2 +- {users => accounts}/migrations/__init__.py | 0 {users => accounts}/models.py | 0 {users => accounts}/tests.py | 0 {users => accounts}/views.py | 23 ++++++++++++++----- computes/views.py | 2 +- instances/views.py | 2 +- templates/{user.html => account.html} | 0 templates/{users.html => accounts.html} | 2 +- templates/navbar.html | 4 ++-- templates/profile.html | 20 ++++++++++++++++ templates/showlogs.html | 4 ++-- templates/sidebar.html | 4 ++-- webvirtcloud/settings.py | 2 +- webvirtcloud/urls.py | 13 +++++------ 20 files changed, 55 insertions(+), 25 deletions(-) rename {users => accounts}/__init__.py (100%) rename {users => accounts}/admin.py (100%) rename {users => accounts}/forms.py (100%) rename {users => accounts}/migrations/0001_initial.py (100%) rename {users => accounts}/migrations/0002_userinstance_is_block.py (91%) rename {users => accounts}/migrations/0003_remove_userinstance_is_block.py (85%) rename {users => accounts}/migrations/__init__.py (100%) rename {users => accounts}/models.py (100%) rename {users => accounts}/tests.py (100%) rename {users => accounts}/views.py (89%) rename templates/{user.html => account.html} (100%) rename templates/{users.html => accounts.html} (97%) create mode 100644 templates/profile.html diff --git a/users/__init__.py b/accounts/__init__.py similarity index 100% rename from users/__init__.py rename to accounts/__init__.py diff --git a/users/admin.py b/accounts/admin.py similarity index 100% rename from users/admin.py rename to accounts/admin.py diff --git a/users/forms.py b/accounts/forms.py similarity index 100% rename from users/forms.py rename to accounts/forms.py diff --git a/users/migrations/0001_initial.py b/accounts/migrations/0001_initial.py similarity index 100% rename from users/migrations/0001_initial.py rename to accounts/migrations/0001_initial.py diff --git a/users/migrations/0002_userinstance_is_block.py b/accounts/migrations/0002_userinstance_is_block.py similarity index 91% rename from users/migrations/0002_userinstance_is_block.py rename to accounts/migrations/0002_userinstance_is_block.py index d6f3a08..ee15938 100644 --- a/users/migrations/0002_userinstance_is_block.py +++ b/accounts/migrations/0002_userinstance_is_block.py @@ -7,7 +7,7 @@ from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ - ('users', '0001_initial'), + ('accounts', '0001_initial'), ] operations = [ diff --git a/users/migrations/0003_remove_userinstance_is_block.py b/accounts/migrations/0003_remove_userinstance_is_block.py similarity index 85% rename from users/migrations/0003_remove_userinstance_is_block.py rename to accounts/migrations/0003_remove_userinstance_is_block.py index 818c2e6..877d915 100644 --- a/users/migrations/0003_remove_userinstance_is_block.py +++ b/accounts/migrations/0003_remove_userinstance_is_block.py @@ -7,7 +7,7 @@ from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ - ('users', '0002_userinstance_is_block'), + ('accounts', '0002_userinstance_is_block'), ] operations = [ diff --git a/users/migrations/__init__.py b/accounts/migrations/__init__.py similarity index 100% rename from users/migrations/__init__.py rename to accounts/migrations/__init__.py diff --git a/users/models.py b/accounts/models.py similarity index 100% rename from users/models.py rename to accounts/models.py diff --git a/users/tests.py b/accounts/tests.py similarity index 100% rename from users/tests.py rename to accounts/tests.py diff --git a/users/views.py b/accounts/views.py similarity index 89% rename from users/views.py rename to accounts/views.py index 6bc0e6d..27bcf11 100644 --- a/users/views.py +++ b/accounts/views.py @@ -3,12 +3,23 @@ from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User -from users.models import UserInstance +from accounts.models import UserInstance from instances.models import Instance -from users.forms import UserAddForm +from accounts.forms import UserAddForm -def users(request): +def profile(request): + """ + :param request: + :return: + """ + if not request.user.is_authenticated(): + return HttpResponseRedirect(reverse('index')) + + return render(request, 'profile.html', locals()) + + +def accounts(request): """ :param request: :return: @@ -64,10 +75,10 @@ def users(request): user_delete.delete() return HttpResponseRedirect(request.get_full_path()) - return render(request, 'users.html', locals()) + return render(request, 'accounts.html', locals()) -def user(request, user_id): +def account(request, user_id): """ :param request: :return: @@ -110,4 +121,4 @@ def user(request, user_id): add_user_inst.save() return HttpResponseRedirect(request.get_full_path()) - return render(request, 'user.html', locals()) \ No newline at end of file + return render(request, 'account.html', locals()) \ No newline at end of file diff --git a/computes/views.py b/computes/views.py index 1596c28..fca3755 100644 --- a/computes/views.py +++ b/computes/views.py @@ -3,7 +3,7 @@ from django.core.urlresolvers import reverse from django.shortcuts import render from computes.models import Compute from instances.models import Instance -from users.models import UserInstance +from accounts.models import UserInstance from computes.forms import ComputeAddTcpForm, ComputeAddSshForm, ComputeEditHostForm, ComputeAddTlsForm, ComputeAddSocketForm from vrtManager.hostdetails import wvmHostDetails from vrtManager.connection import CONN_SSH, CONN_TCP, CONN_TLS, CONN_SOCKET, connection_manager diff --git a/instances/views.py b/instances/views.py index 77c6c98..30bd83b 100644 --- a/instances/views.py +++ b/instances/views.py @@ -7,7 +7,7 @@ from django.shortcuts import render from django.utils.translation import ugettext_lazy as _ from computes.models import Compute from instances.models import Instance -from users.models import UserInstance +from accounts.models import UserInstance from vrtManager.hostdetails import wvmHostDetails from vrtManager.instance import wvmInstance, wvmInstances from vrtManager.connection import connection_manager diff --git a/templates/user.html b/templates/account.html similarity index 100% rename from templates/user.html rename to templates/account.html diff --git a/templates/users.html b/templates/accounts.html similarity index 97% rename from templates/users.html rename to templates/accounts.html index 01e7d20..3ffe8ec 100644 --- a/templates/users.html +++ b/templates/accounts.html @@ -19,7 +19,7 @@

- {{ user.username }} + {{ user.username }} diff --git a/templates/navbar.html b/templates/navbar.html index 6c58389..acb93a0 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -16,11 +16,11 @@ {{ request.user.username }} diff --git a/templates/profile.html b/templates/profile.html new file mode 100644 index 0000000..d2a0b1c --- /dev/null +++ b/templates/profile.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} +{% load i18n %} +{% block title %}{% trans "Logs" %}{% endblock %} +{% block content %} + +
+
+

{% trans "Profile" %}

+
+
+ + + {% include 'errors_block.html' %} + +
+
+ +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/showlogs.html b/templates/showlogs.html index 9716957..4383dfd 100644 --- a/templates/showlogs.html +++ b/templates/showlogs.html @@ -37,8 +37,8 @@ {% for log in logs %} {{ forloop.counter }} - {{ log.user }} - {{ log.instance }} + {{ log.user }} + {{ log.instance }} {{ log.message }} {{ log.date|date:"M d H:i:s" }} diff --git a/templates/sidebar.html b/templates/sidebar.html index b1115e8..869f19c 100644 --- a/templates/sidebar.html +++ b/templates/sidebar.html @@ -10,8 +10,8 @@
  • {% trans "Computes" %}
  • -
  • - {% trans "Users" %} +
  • + {% trans "Users" %}
  • {% trans "Logs" %} diff --git a/webvirtcloud/settings.py b/webvirtcloud/settings.py index 2ac4bdd..8dd70b9 100644 --- a/webvirtcloud/settings.py +++ b/webvirtcloud/settings.py @@ -23,7 +23,7 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'computes', 'instances', - 'users', + 'accounts', 'create', 'logs', ) diff --git a/webvirtcloud/urls.py b/webvirtcloud/urls.py index fd55e5c..46660fa 100644 --- a/webvirtcloud/urls.py +++ b/webvirtcloud/urls.py @@ -2,11 +2,11 @@ from django.conf.urls import patterns, include, url from django.contrib import admin urlpatterns = patterns('', - url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'), - url(r'^logout/$', 'django.contrib.auth.views.logout', {'template_name': 'logout.html'}, name='logout'), - - url(r'^login/$', 'django.contrib.auth.views.login'), - url(r'^logout/$', 'django.contrib.auth.views.logout'), + url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'), + url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', {'template_name': 'logout.html'}, name='logout'), + url(r'^accounts/profile/$', 'accounts.views.profile', name='profile'), + url(r'^accounts/$', 'accounts.views.accounts', name='accounts'), + url(r'^accounts/profile/(\d+)/$', 'accounts.views.account', name='account'), url(r'^$', 'instances.views.index', name='index'), url(r'^instances$', 'instances.views.instances', name='instances'), @@ -26,8 +26,7 @@ urlpatterns = patterns('', url(r'^compute/secret/(\d+)/$', 'secrets.views.secrets', name='secrets'), - 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'),