mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
Add new rule and tags
This commit is contained in:
parent
5960e94da5
commit
8f5ccb3519
13 changed files with 156 additions and 27 deletions
0
computes/templatetags/__init__.py
Normal file
0
computes/templatetags/__init__.py
Normal file
11
computes/templatetags/tags_activebtn.py
Normal file
11
computes/templatetags/tags_activebtn.py
Normal file
|
@ -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 ''
|
|
@ -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 ''
|
|
@ -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 = []
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
{% include 'errors_block.html' %}
|
||||
|
||||
{% include 'compute_block_link.html' %}
|
||||
|
||||
<h4>{% trans "Basic details" %}</h4>
|
||||
|
||||
<div class="table-responsive">
|
||||
|
|
8
templates/compute_block_link.html
Normal file
8
templates/compute_block_link.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% load i18n %}
|
||||
{% load tags_activebtn %}
|
||||
<a href="{% url 'storages' compute.id %}" class="btn btn-default {% class_activebtn request "^/storage" %}">{% trans "Storages" %}</a>
|
||||
<a href="{% url 'networks' compute.id %}" class="btn btn-default {% class_activebtn request "^/network" %}">{% trans "Networks" %}</a>
|
||||
<a href="{% url 'interfaces' compute.id %}" class="btn btn-default {% class_activebtn request "^/interface" %}">{% trans "Interface" %}</a>
|
||||
<a href="{% url 'secrets' compute.id %}" class="btn btn-default {% class_activebtn request "^/secret" %}">{% trans "Secrets" %}</a>
|
||||
|
||||
<hr>
|
27
templates/interfaces.html
Normal file
27
templates/interfaces.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Interfaces" %} - {{ compute.name }}{% 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">
|
||||
|
||||
{% include "create_stg_block.html" %}
|
||||
|
||||
<h1 class="page-header">{{ compute.name }}</h1>
|
||||
|
||||
{% include 'compute_block_link.html' %}
|
||||
|
||||
{% include 'errors_block.html' %}
|
||||
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
27
templates/networks.html
Normal file
27
templates/networks.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Network" %} - {{ compute.name }}{% 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">
|
||||
|
||||
{% include "create_stg_block.html" %}
|
||||
|
||||
<h1 class="page-header">{{ compute.name }}</h1>
|
||||
|
||||
{% include 'compute_block_link.html' %}
|
||||
|
||||
{% include 'errors_block.html' %}
|
||||
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
27
templates/secrets.html
Normal file
27
templates/secrets.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Secrets" %} - {{ compute.name }}{% 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">
|
||||
|
||||
{% include "create_stg_block.html" %}
|
||||
|
||||
<h1 class="page-header">{{ compute.name }}</h1>
|
||||
|
||||
{% include 'compute_block_link.html' %}
|
||||
|
||||
{% include 'errors_block.html' %}
|
||||
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -4,14 +4,14 @@
|
|||
<a class="logo" href="{% url 'instances' %}">WebVirtCloud</a>
|
||||
<hr>
|
||||
<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 class="{% class_active request "^/instance" %}"><a href="{% url 'instances' %}"><span class="glyphicon glyphicon-th" aria-hidden="true"></span></a></li>
|
||||
{% if request.user.is_superuser %}
|
||||
<li {% active request "^/compute" %}><a href="{% url 'computes' %}"><span class="glyphicon glyphicon-tasks" 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 {% active request "^/showlogs" %}><a href="{% url 'showlogs' %}"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a></li>
|
||||
<li class="{% class_active request "^/compute" %}"><a href="{% url 'computes' %}"><span class="glyphicon glyphicon-tasks" aria-hidden="true"></span></a></li>
|
||||
<li class="{% class_active request "^/user" %}"><a href="{% url 'users' %}"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a></li>
|
||||
<li class="{% class_active request "^/log" %}"><a href="{% url 'showlogs' %}"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a></li>
|
||||
{% endif %}
|
||||
<li class="bottom-sticky">
|
||||
<a href="#"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span></a>
|
||||
<a class="{% class_active request "^/account" %}" 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>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
27
templates/storages.html
Normal file
27
templates/storages.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Storages" %} - {{ compute.name }}{% 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">
|
||||
|
||||
{% include "create_stg_block.html" %}
|
||||
|
||||
<h1 class="page-header">{{ compute.name }}</h1>
|
||||
|
||||
{% include 'compute_block_link.html' %}
|
||||
|
||||
{% include 'errors_block.html' %}
|
||||
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -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'),
|
||||
|
|
Loading…
Reference in a new issue