From 8f5ccb351910f3b9903de89626ead0e5544f79ec Mon Sep 17 00:00:00 2001 From: Retspen Date: Tue, 3 Mar 2015 16:53:10 +0200 Subject: [PATCH] Add new rule and tags --- computes/templatetags/__init__.py | 0 computes/templatetags/tags_activebtn.py | 11 +++++++++ instances/templatetags/tags_active.py | 4 ++-- networks/views.py | 2 +- templates/compute.html | 2 ++ templates/compute_block_link.html | 8 +++++++ templates/interfaces.html | 27 +++++++++++++++++++++ templates/networks.html | 27 +++++++++++++++++++++ templates/secrets.html | 27 +++++++++++++++++++++ templates/showlogs.html | 2 +- templates/sidebar.html | 32 ++++++++++++------------- templates/storages.html | 27 +++++++++++++++++++++ webvirtcloud/urls.py | 14 +++++------ 13 files changed, 156 insertions(+), 27 deletions(-) create mode 100644 computes/templatetags/__init__.py create mode 100644 computes/templatetags/tags_activebtn.py create mode 100644 templates/compute_block_link.html create mode 100644 templates/interfaces.html create mode 100644 templates/networks.html create mode 100644 templates/secrets.html create mode 100644 templates/storages.html diff --git a/computes/templatetags/__init__.py b/computes/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/computes/templatetags/tags_activebtn.py b/computes/templatetags/tags_activebtn.py new file mode 100644 index 0000000..70360c8 --- /dev/null +++ b/computes/templatetags/tags_activebtn.py @@ -0,0 +1,11 @@ +from django import template +import re + +register = template.Library() + + +@register.simple_tag +def class_activebtn(request, pattern): + if re.search(pattern, request.path): + return 'btn-primary' + return '' \ No newline at end of file diff --git a/instances/templatetags/tags_active.py b/instances/templatetags/tags_active.py index b423c5d..547f8de 100644 --- a/instances/templatetags/tags_active.py +++ b/instances/templatetags/tags_active.py @@ -5,7 +5,7 @@ register = template.Library() @register.simple_tag -def active(request, pattern): +def class_active(request, pattern): if re.search(pattern, request.path): - return 'class="active"' + return 'active' return '' \ No newline at end of file diff --git a/networks/views.py b/networks/views.py index fae23a2..78b3d82 100644 --- a/networks/views.py +++ b/networks/views.py @@ -18,7 +18,7 @@ def networks(request, compute_id): if not request.user.is_authenticated(): return HttpResponseRedirect(reverse('index')) - if not request.user.is_superuser(): + if not request.user.is_superuser: return HttpResponseRedirect(reverse('index')) error_messages = [] diff --git a/templates/compute.html b/templates/compute.html index 9a5544f..dc38ef6 100644 --- a/templates/compute.html +++ b/templates/compute.html @@ -15,6 +15,8 @@ {% include 'errors_block.html' %} + {% include 'compute_block_link.html' %} +

{% trans "Basic details" %}

diff --git a/templates/compute_block_link.html b/templates/compute_block_link.html new file mode 100644 index 0000000..93a3ecf --- /dev/null +++ b/templates/compute_block_link.html @@ -0,0 +1,8 @@ +{% load i18n %} +{% load tags_activebtn %} +{% trans "Storages" %} +{% trans "Networks" %} +{% trans "Interface" %} +{% trans "Secrets" %} + +
\ No newline at end of file diff --git a/templates/interfaces.html b/templates/interfaces.html new file mode 100644 index 0000000..f4ca3eb --- /dev/null +++ b/templates/interfaces.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} +{% load i18n %} +{% block title %}{% trans "Interfaces" %} - {{ compute.name }}{% endblock %} +{% block content %} +
+
+ + {% include 'sidebar.html' %} + +
+ + {% include "create_stg_block.html" %} + +

{{ compute.name }}

+ + {% include 'compute_block_link.html' %} + + {% include 'errors_block.html' %} + +
+ +
+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/networks.html b/templates/networks.html new file mode 100644 index 0000000..a81a0cd --- /dev/null +++ b/templates/networks.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} +{% load i18n %} +{% block title %}{% trans "Network" %} - {{ compute.name }}{% endblock %} +{% block content %} +
+
+ + {% include 'sidebar.html' %} + +
+ + {% include "create_stg_block.html" %} + +

{{ compute.name }}

+ + {% include 'compute_block_link.html' %} + + {% include 'errors_block.html' %} + +
+ +
+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/secrets.html b/templates/secrets.html new file mode 100644 index 0000000..a6dd73a --- /dev/null +++ b/templates/secrets.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} +{% load i18n %} +{% block title %}{% trans "Secrets" %} - {{ compute.name }}{% endblock %} +{% block content %} +
+
+ + {% include 'sidebar.html' %} + +
+ + {% include "create_stg_block.html" %} + +

{{ compute.name }}

+ + {% include 'compute_block_link.html' %} + + {% include 'errors_block.html' %} + +
+ +
+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/showlogs.html b/templates/showlogs.html index 5678856..88c9d2d 100644 --- a/templates/showlogs.html +++ b/templates/showlogs.html @@ -8,7 +8,7 @@ {% include 'sidebar.html' %}
- +

{% trans "Logs" %}

{% include 'errors_block.html' %} diff --git a/templates/sidebar.html b/templates/sidebar.html index 5640ea4..17b056c 100644 --- a/templates/sidebar.html +++ b/templates/sidebar.html @@ -1,18 +1,18 @@ {% load i18n %} {% load tags_active %} - \ No newline at end of file + \ No newline at end of file diff --git a/templates/storages.html b/templates/storages.html new file mode 100644 index 0000000..995ed68 --- /dev/null +++ b/templates/storages.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} +{% load i18n %} +{% block title %}{% trans "Storages" %} - {{ compute.name }}{% endblock %} +{% block content %} +
+
+ + {% include 'sidebar.html' %} + +
+ + {% include "create_stg_block.html" %} + +

{{ compute.name }}

+ + {% include 'compute_block_link.html' %} + + {% include 'errors_block.html' %} + +
+ +
+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/webvirtcloud/urls.py b/webvirtcloud/urls.py index 1828b1b..268a542 100644 --- a/webvirtcloud/urls.py +++ b/webvirtcloud/urls.py @@ -15,16 +15,16 @@ urlpatterns = patterns('', url(r'^computes/$', 'computes.views.computes', name='computes'), url(r'^compute/(\d+)/$', 'computes.views.compute', name='compute'), - url(r'^storages/(\d+)/$', 'storages.views.storages', name='storages'), - url(r'^storage/(\d+)/([\w\-\.]+)/$', 'storages.views.storage', name='storage'), + url(r'^compute/stgs/(\d+)/$', 'storages.views.storages', name='storages'), + url(r'^compute/stg/(\d+)/([\w\-\.]+)/$', 'storages.views.storage', name='storage'), - url(r'^networks/(\d+)/$', 'networks.views.networks', name='networks'), - url(r'^network/(\d+)/([\w\-\.]+)/$', 'networks.views.network', name='network'), + url(r'^compute/nets/(\d+)/$', 'networks.views.networks', name='networks'), + url(r'^compute/net/(\d+)/([\w\-\.]+)/$', 'networks.views.network', name='network'), - url(r'^interfaces/(\d+)/$', 'interfaces.views.interfaces', name='interfaces'), - url(r'^interface/(\d+)/([\w\.]+)$', 'interfaces.views.interface', name='interface'), + url(r'^compute/ifaces/(\d+)/$', 'interfaces.views.interfaces', name='interfaces'), + url(r'^compute/iface/(\d+)/([\w\.]+)$', 'interfaces.views.interface', name='interface'), - url(r'^secret/(\d+)/$', 'secrets.views.secrets', name='secrets'), + 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'),