From 6d2ad5b00e09109ac71a1b84d9536148aadfdb5b Mon Sep 17 00:00:00 2001 From: Yoann Pietri Date: Sun, 15 Nov 2020 20:41:23 +0100 Subject: [PATCH] Refactor navbar and general frontend. The menus of the navbar is reorganized The footer is changed into a navbar The right sidebar is placed to the left The left sidebar is deleted Header navbar and leftsidebar are now fixed Physical grouing is split into 4 views --- .../templates/cotisations/sidebar.html | 38 -- logs/templates/logs/sidebar.html | 30 -- machines/templates/machines/sidebar.html | 54 --- .../preferences/display_preferences.html | 1 + static/css/base.css | 67 ++- static/js/main.js | 42 ++ templates/base.html | 381 ++++-------------- templates/footer.html | 53 +++ templates/nav.html | 322 +++++++++++++++ templates/sidebar.html | 136 +++++++ .../templates/topologie/index_building.html | 42 ++ ...cal_grouping.html => index_dormitory.html} | 27 -- .../templates/topologie/index_stack.html | 41 ++ .../templates/topologie/index_switch_bay.html | 42 ++ topologie/templates/topologie/sidebar.html | 30 -- topologie/urls.py | 21 +- topologie/views.py | 110 +++-- users/templates/users/sidebar.html | 68 ---- 18 files changed, 896 insertions(+), 609 deletions(-) create mode 100644 static/js/main.js create mode 100644 templates/footer.html create mode 100644 templates/nav.html create mode 100644 templates/sidebar.html create mode 100644 topologie/templates/topologie/index_building.html rename topologie/templates/topologie/{index_physical_grouping.html => index_dormitory.html} (60%) create mode 100644 topologie/templates/topologie/index_stack.html create mode 100644 topologie/templates/topologie/index_switch_bay.html diff --git a/cotisations/templates/cotisations/sidebar.html b/cotisations/templates/cotisations/sidebar.html index 8e69a8c9..4b0f3392 100644 --- a/cotisations/templates/cotisations/sidebar.html +++ b/cotisations/templates/cotisations/sidebar.html @@ -27,43 +27,5 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load i18n %} {% block sidebar %} - {% can_create CustomInvoice %} - - {% trans "Create an invoice" %} - - - {% trans "Control the invoices" %} - - {% acl_end %} - {% can_view_all Facture %} - - {% trans "Invoices" %} - - {% acl_end %} - {% can_view_all CustomInvoice %} - - {% trans "Custom invoices" %} - - {% acl_end %} - {% can_view_all CostEstimate %} - - {% trans "Cost estimates" %} - - {% acl_end %} - {% can_view_all Article %} - - {% trans "Articles" %} - - {% acl_end %} - {% can_view_all Banque %} - - {% trans "Banks" %} - - {% acl_end %} - {% can_view_all Paiement %} - - {% trans "Payment methods" %} - - {% acl_end %} {% endblock %} diff --git a/logs/templates/logs/sidebar.html b/logs/templates/logs/sidebar.html index a44da9e3..4b0f3392 100644 --- a/logs/templates/logs/sidebar.html +++ b/logs/templates/logs/sidebar.html @@ -27,35 +27,5 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load i18n %} {% block sidebar %} - {% can_view_app logs %} - - - {% trans "Summary" %} - - - - {% trans "Events" %} - - - - {% trans "General" %} - - - - {% trans "Database" %} - - - - {% trans "Wiring actions" %} - - - - {% trans "Users" %} - - - - {% trans "Machine history" %} - - {% acl_end %} {% endblock %} diff --git a/machines/templates/machines/sidebar.html b/machines/templates/machines/sidebar.html index 0993f33c..4b0f3392 100644 --- a/machines/templates/machines/sidebar.html +++ b/machines/templates/machines/sidebar.html @@ -27,59 +27,5 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load i18n %} {% block sidebar %} - {% can_view_all Machine %} - - - {% trans "Machines" %} - - {% acl_end %} - {% can_view_all MachineType %} - - - {% trans "Machine types" %} - - {% acl_end %} - {% can_view_all Extension %} - - - {% trans "Extensions and zones" %} - - {% acl_end %} - {% can_view_all IpType %} - - - {% trans "IP ranges" %} - - {% acl_end %} - {% can_view_all Vlan %} - - - {% trans "VLANs" %} - - {% acl_end %} - {% can_view_all Nas %} - - - {% trans "NAS devices" %} - - {% acl_end %} - {% can_view_all machines.Service %} - - - {% trans "Services (DHCP, DNS, ...)" %} - - {% acl_end %} - {% can_view_all Role %} - - - {% trans "Server roles" %} - - {% acl_end %} - {% can_view_all OuverturePortList %} - - - {% trans "Ports openings" %} - - {% acl_end %} {% endblock %} diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html index ede55c25..e2de0ee0 100644 --- a/preferences/templates/preferences/display_preferences.html +++ b/preferences/templates/preferences/display_preferences.html @@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Preferences" %}{% endblock %} {% block content %} +

{% trans "Preferences" %}

diff --git a/static/css/base.css b/static/css/base.css index c1b8bcbc..14032f4e 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -1,3 +1,12 @@ +/* For the footer to be at the bottom*/ +body { + padding-top: 50px; +} + +.content { + min-height: calc(100vh - 100px); +} + /* Footer */ footer { padding-top: 3rem; @@ -70,10 +79,52 @@ a > i.fa { } /* Set gray background color */ -.sidenav { - background-color: #f1f1f1; - border: 1px solid #e0e0e0; - border-radius: 0 0 5px 5px; +@media (min-width: 768px) { + .sidenav-right { + position: fixed; + top:50px; + right:0; + } + .sidenav-left { + position: fixed; + top:50px; + left:0; + } + .dropdown-menu .dropdown-toggle:after { + border-top: .3em solid transparent; + border-right: 0; + border-bottom: .3em solid transparent; + border-left: .3em solid; + } + + .dropdown-menu .dropdown-menu { + margin-left: 0; + margin-right: 0; + } + + .dropdown-menu li { + position: relative; + } + + .nav-item .submenu { + display: none; + position: absolute; + left: 100%; + top: -7px; + } + + .nav-item .submenu-left { + right: 100%; + left: auto; + } + + .dropdown-menu>li:hover { + background-color: #f1f1f1 + } + + .dropdown-menu>li:hover>.submenu { + display: block; + } } .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th { vertical-align: middle; @@ -148,3 +199,11 @@ dl.profile-info > div { [data-toggle~="collapse"] { cursor: pointer; } + +/* Indent for submenu when collapsed */ + +@media (max-width:767px) { + .submenu > li { + margin-left:20px; + } +}; \ No newline at end of file diff --git a/static/js/main.js b/static/js/main.js new file mode 100644 index 00000000..d3b82cca --- /dev/null +++ b/static/js/main.js @@ -0,0 +1,42 @@ +function adjustHeader(){ + /* This function is here to adjust the header if the header navbar + goes into two lines. This can't happen if the width is sm or less, + and we shouldn't adjust in this case. */ + if ($(window).width() >= 768) { + $('body').css('padding-top', $("#navbar-header").height()); + $('.sidenav-left').css('top', $("#navbar-header").height()); + } else { + $('body').css('padding-top', ''); + $('.sidenav-left').css('top', ''); + } +} + +function listenSubmenu() { + /* Add listeners on sm screen or less for submenus. */ + if ($(window).width() < 767) { + $('.dropdown-menu a').click(function (e) { + if ($(this).next('.submenu').length) { + e.preventDefault(); + $(this).next('.submenu').toggle(); + } + $('.dropdown').on('hide.bs.dropdown', function () { + $(this).find('.submenu').hide(); + }) + }); + } +} + +/* We need to apply those functions at init and when the screen is resized. */ + +$(window).resize(function () { + adjustHeader(); + listenSubmenu(); +}); + +adjustHeader(); +listenSubmenu(); + + +$(document).on('click', '.dropdown-menu', function (e) { + e.stopPropagation(); +}); \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index e4bde7f3..d8a2f87b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,8 +3,8 @@ Re2o est un logiciel d'administration développé initiallement au rezometz. Il se veut agnostique au réseau considéré, de manière à être installable en quelques clics. -Copyright © 2017 Lara Kermarec -Copyright © 2017 Augustin Lemesle +Copyright © 2017 Lara Kermarec +Copyright © 2017 Augustin Lemesle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ the Free Software Foundation; either version 2 of the License, or This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along @@ -32,327 +32,82 @@ with this program; if not, write to the Free Software Foundation, Inc., {% self_adhesion as var_sa %} - - {# Open Graph for social media #} - - - - - - - - {# Preload JavaScript #} - {% bootstrap_javascript %} - - - + + {# Open Graph for social media #} + + + + + + + - {% block custom_js %}{% endblock %} + {# Preload JavaScript #} + {% bootstrap_javascript %} + + + - {# Load CSS #} - {% bootstrap_css %} - - - - + {% block custom_js %}{% endblock %} - {# Favicon with iOS, Android, touchbar support #} - - - - - - - + {# Load CSS #} + {% bootstrap_css %} + + + + - {# Do not allow zooming on devices #} - + {# Favicon with iOS, Android, touchbar support #} + + + + + + + - {{ name_website }} : {% block title %}{% trans "Home" %}{% endblock %} - + {# Do not allow zooming on devices #} + - - - -
-
-
-
-
- {% block sidebar %} - {% endblock %} -
-
-
-
- {# Display django.contrib.messages as Bootstrap alerts #} - {% bootstrap_messages %} - {% block content %}{% endblock %} -
-
-
- {% if request_user.is_authenticated %} -
-

{{ request_user.name }} {{ request_user.surname }}

-
- - - - - - - - - - - - - -
- {% trans "Username" %} -
- {{ request_user.pseudo }} -
- {% trans "Room" %} -
- {{ request_user.room }} -
- {% trans "Internet access" %} -
- {% if request_user.has_access %} - {% blocktrans with end_access_date=request.user.end_access|date:"d b Y" %}Until {{ end_access_date }}{% endblocktrans %} - {% else %} - {% trans "Disabled" %} - {% endif %} -
- {% trans "Membership" %} -
- {% if request_user.is_adherent %} - {% blocktrans with end_adhesion_date=request_user.end_adhesion|date:"d b Y" %}Until {{ end_adhesion_date }}{% endblocktrans %} - {% else %} - {% trans "Non member" %} - {% endif %} -
- - - - - - - - - - - - - - - - - - -
{% trans "Username" %}{{ request_user.pseudo }}
{% trans "Room" %}{{ request_user.room }}
{% trans "Internet access" %} - {% if request_user.has_access %} - {% blocktrans with end_access_date=request.user.end_access|date:"d b Y" %}Until {{ end_access_date }}{% endblocktrans %} - {% else %} - {% trans "Disabled" %} - {% endif %} -
{% trans "Membership" %} - {% if request_user.is_adherent %} - {% blocktrans with end_adhesion_date=request_user.end_adhesion|date:"d b Y" %}Until {{ end_adhesion_date }}{% endblocktrans %} - {% else %} - {% trans "Non member" %} - {% endif %} -
- - {% else %} -
-

{% trans "You are not logged in." %}

-
- {% endif %} -
- {% if request_user.is_authenticated %} -
-
-

{% blocktrans count interfaces|length as nb %}{{ nb }} active machine{% plural %}{{ nb }} active machines{% endblocktrans %}

-
- -
- {% endif %} -
+
+ {# Display django.contrib.messages as Bootstrap alerts #} + {% bootstrap_messages %} + {% block content %}{% endblock %}
+
-
-
-

- {% trans "Back to top" %} -

-

{{ name_website }} {% trans "powered by" %} Re2o 2016–2020

-

- {% blocktrans trimmed %} - Brought to you with . - {% endblocktrans %} - {% trans "About this website" %}. -

-

- {% blocktrans trimmed %} - This software is under the terms of the - GPLv2 License. - {% endblocktrans %} -

-
-
+ {% include 'footer.html' %} - {# Load JavaScript #} - - - - {% if request.user.shortcuts_enabled %} - - {% endif %} - {# Read the documentation for more information #} - - + {# Load JavaScript #} + + + + {% if request.user.shortcuts_enabled %} + + {% endif %} + {# Read the documentation for more information #} + + + \ No newline at end of file diff --git a/templates/footer.html b/templates/footer.html new file mode 100644 index 00000000..25990629 --- /dev/null +++ b/templates/footer.html @@ -0,0 +1,53 @@ +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Lara Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +{% endcomment %} + +{% load i18n %} +{% load static %} + \ No newline at end of file diff --git a/templates/nav.html b/templates/nav.html new file mode 100644 index 00000000..b48c97c8 --- /dev/null +++ b/templates/nav.html @@ -0,0 +1,322 @@ +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Lara Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +{% endcomment %} + +{% load static %} +{% load acl %} +{% load i18n %} + \ No newline at end of file diff --git a/templates/sidebar.html b/templates/sidebar.html new file mode 100644 index 00000000..08600b30 --- /dev/null +++ b/templates/sidebar.html @@ -0,0 +1,136 @@ +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Lara Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +{% endcomment %} + +{% load i18n %} + +
+ {% if request_user.is_authenticated %} +
+

{{ request_user.name }} {{ request_user.surname }}

+
+ + + + + + + + + + + + + +
+ {% trans "Username" %} +
+ {{ request_user.pseudo }} +
+ {% trans "Room" %} +
+ {{ request_user.room }} +
+ {% trans "Internet access" %} +
+ {% if request_user.has_access %} + {% blocktrans with end_access_date=request.user.end_access|date:"d b Y" %}Until + {{ end_access_date }}{% endblocktrans %} + {% else %} + {% trans "Disabled" %} + {% endif %} +
+ {% trans "Membership" %} +
+ {% if request_user.is_adherent %} + {% blocktrans with end_adhesion_date=request_user.end_adhesion|date:"d b Y" %}Until + {{ end_adhesion_date }}{% endblocktrans %} + {% else %} + {% trans "Non member" %} + {% endif %} +
+ + + + + + + + + + + + + + + + + + +
{% trans "Username" %}{{ request_user.pseudo }}
{% trans "Room" %}{{ request_user.room }}
{% trans "Internet access" %} + {% if request_user.has_access %} + {% blocktrans with end_access_date=request.user.end_access|date:"d b Y" %}Until + {{ end_access_date }}{% endblocktrans %} + {% else %} + {% trans "Disabled" %} + {% endif %} +
{% trans "Membership" %} + {% if request_user.is_adherent %} + {% blocktrans with end_adhesion_date=request_user.end_adhesion|date:"d b Y" %}Until + {{ end_adhesion_date }}{% endblocktrans %} + {% else %} + {% trans "Non member" %} + {% endif %} +
+ + {% else %} +
+

{% trans "You are not logged in." %}

+
+ {% endif %} +
+{% if request_user.is_authenticated %} +
+
+

{% blocktrans count interfaces|length as nb %}{{ nb }} active machine{% plural %}{{ nb }} + active machines{% endblocktrans %}

+
+ +
+{% endif %} \ No newline at end of file diff --git a/topologie/templates/topologie/index_building.html b/topologie/templates/topologie/index_building.html new file mode 100644 index 00000000..d653a032 --- /dev/null +++ b/topologie/templates/topologie/index_building.html @@ -0,0 +1,42 @@ +{% extends 'topologie/sidebar.html' %} +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Gabriel Détraz +Copyright © 2017 Lara Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +{% endcomment %} + +{% load bootstrap3 %} +{% load acl %} +{% load i18n %} + +{% block title %}{% trans "Topology" %}{% endblock %} + +{% block content %} +

{% trans "Buildings" %}

+ {% can_create Building %} + + {% trans "Add a building" %} + +
+ {% acl_end %} + {% include 'topologie/aff_building.html' with building_list=building_list %} +{% endblock %} + diff --git a/topologie/templates/topologie/index_physical_grouping.html b/topologie/templates/topologie/index_dormitory.html similarity index 60% rename from topologie/templates/topologie/index_physical_grouping.html rename to topologie/templates/topologie/index_dormitory.html index cea4fb75..c137bb70 100644 --- a/topologie/templates/topologie/index_physical_grouping.html +++ b/topologie/templates/topologie/index_dormitory.html @@ -30,33 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}{% trans "Topology" %}{% endblock %} {% block content %} -

{% trans "Stacks" %}

- {% can_create Stack %} - - {% trans "Add a stack" %} - - {% acl_end %} - {% include 'topologie/aff_stacks.html' with stack_list=stack_list %} - -

{% trans "Switch bays" %}

- {% can_create SwitchBay %} - - {% trans "Add a switch bay" %} - -
- {% acl_end %} - {% include 'topologie/aff_switch_bay.html' with switch_bay_list=switch_bay_list %} - -

{% trans "Buildings" %}

- {% can_create Building %} - - {% trans "Add a building" %} - -
- {% acl_end %} - {% include 'topologie/aff_building.html' with building_list=building_list %} - -

{% trans "Dormitories" %}

{% can_create Dormitory %} diff --git a/topologie/templates/topologie/index_stack.html b/topologie/templates/topologie/index_stack.html new file mode 100644 index 00000000..6006167f --- /dev/null +++ b/topologie/templates/topologie/index_stack.html @@ -0,0 +1,41 @@ +{% extends 'topologie/sidebar.html' %} +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Gabriel Détraz +Copyright © 2017 Lara Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +{% endcomment %} + +{% load bootstrap3 %} +{% load acl %} +{% load i18n %} + +{% block title %}{% trans "Topology" %}{% endblock %} + +{% block content %} +

{% trans "Stacks" %}

+ {% can_create Stack %} +
+ {% trans "Add a stack" %} + + {% acl_end %} + {% include 'topologie/aff_stacks.html' with stack_list=stack_list %} +{% endblock %} + diff --git a/topologie/templates/topologie/index_switch_bay.html b/topologie/templates/topologie/index_switch_bay.html new file mode 100644 index 00000000..f3613e48 --- /dev/null +++ b/topologie/templates/topologie/index_switch_bay.html @@ -0,0 +1,42 @@ +{% extends 'topologie/sidebar.html' %} +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Gabriel Détraz +Copyright © 2017 Lara Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +{% endcomment %} + +{% load bootstrap3 %} +{% load acl %} +{% load i18n %} + +{% block title %}{% trans "Topology" %}{% endblock %} + +{% block content %} +

{% trans "Switch bays" %}

+ {% can_create SwitchBay %} + + {% trans "Add a switch bay" %} + +
+ {% acl_end %} + {% include 'topologie/aff_switch_bay.html' with switch_bay_list=switch_bay_list %} +{% endblock %} + diff --git a/topologie/templates/topologie/sidebar.html b/topologie/templates/topologie/sidebar.html index f90e5d55..751fff3c 100644 --- a/topologie/templates/topologie/sidebar.html +++ b/topologie/templates/topologie/sidebar.html @@ -23,36 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} -{% load i18n %} {% block sidebar %} - - - {% trans "Rooms and premises" %} - - - - {% trans "Switches" %} - - - - {% trans "Switch modules" %} - - - - {% trans "Port profiles" %} - - - - {% trans "Access points" %} - - - - {% trans "Physical grouping" %} - - - - {% trans "Switch models and constructors" %} - {% endblock %} - diff --git a/topologie/urls.py b/topologie/urls.py index 4baf8234..f387c226 100644 --- a/topologie/urls.py +++ b/topologie/urls.py @@ -49,9 +49,24 @@ urlpatterns = [ url(r"^edit_switch/(?P[0-9]+)$", views.edit_switch, name="edit-switch"), url(r"^new_stack/$", views.new_stack, name="new-stack"), url( - r"^index_physical_grouping/$", - views.index_physical_grouping, - name="index-physical-grouping", + r"^index_stack/$", + views.index_stack, + name="index-stack", + ), + url( + r"^index_switch_bay/$", + views.index_switch_bay, + name="index-switch-bay", + ), + url( + r"^index_building/$", + views.index_building, + name="index-building", + ), + url( + r"^index_dormitory/$", + views.index_dormitory, + name="index-dormitory", ), url(r"^edit_stack/(?P[0-9]+)$", views.edit_stack, name="edit-stack"), url(r"^del_stack/(?P[0-9]+)$", views.del_stack, name="del-stack"), diff --git a/topologie/views.py b/topologie/views.py index 3b1aad30..06eaf410 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -242,35 +242,12 @@ def index_ap(request): @login_required -@can_view_all(Stack, Building, Dormitory, SwitchBay) -def index_physical_grouping(request): - """View used to display the list of stacks (display all switches).""" - stack_list = Stack.objects.prefetch_related( - "switch_set__interface_set__domain__extension" - ) - building_list = Building.objects.all().select_related("dormitory") - dormitory_list = Dormitory.objects.all().prefetch_related("building_set") +@can_view_all(SwitchBay) +def index_switch_bay(request): + """View used to display the list of switch bays.""" switch_bay_list = SwitchBay.objects.select_related( "building__dormitory" ).prefetch_related("switch_set__interface_set__domain") - stack_list = SortTable.sort( - stack_list, - request.GET.get("col"), - request.GET.get("order"), - SortTable.TOPOLOGIE_INDEX_STACK, - ) - building_list = SortTable.sort( - building_list, - request.GET.get("col"), - request.GET.get("order"), - SortTable.TOPOLOGIE_INDEX_BUILDING, - ) - dormitory_list = SortTable.sort( - dormitory_list, - request.GET.get("col"), - request.GET.get("order"), - SortTable.TOPOLOGIE_INDEX_DORMITORY, - ) switch_bay_list = SortTable.sort( switch_bay_list, request.GET.get("col"), @@ -279,15 +256,64 @@ def index_physical_grouping(request): ) return render( request, - "topologie/index_physical_grouping.html", + "topologie/index_switch_bay.html", { - "stack_list": stack_list, "switch_bay_list": switch_bay_list, - "building_list": building_list, - "dormitory_list": dormitory_list, }, ) +@login_required +@can_view_all(Stack) +def index_stack(request): + """View used to display the list of stacks (display all switches).""" + stack_list = Stack.objects.prefetch_related( + "switch_set__interface_set__domain__extension" + ) + return render( + request, + "topologie/index_stack.html", + { + "stack_list": stack_list, + }, + ) + +@login_required +@can_view_all(Building) +def index_building(request): + """View used to display the list of buildings""" + building_list = Building.objects.all().select_related("dormitory") + building_list = SortTable.sort( + building_list, + request.GET.get("col"), + request.GET.get("order"), + SortTable.TOPOLOGIE_INDEX_BUILDING, + ) + return render( + request, + "topologie/index_building.html", + { + "building_list": building_list, + }, + ) + +@login_required +@can_view_all(Dormitory) +def index_dormitory(request): + """View used to display the list of dormitories.""" + dormitory_list = Dormitory.objects.all().prefetch_related("building_set") + dormitory_list = SortTable.sort( + dormitory_list, + request.GET.get("col"), + request.GET.get("order"), + SortTable.TOPOLOGIE_INDEX_DORMITORY, + ) + return render( + request, + "topologie/index_dormitory.html", + { + "dormitory_list": dormitory_list, + }, + ) @login_required @can_view_all(ModelSwitch, ConstructorSwitch) @@ -440,7 +466,7 @@ def new_stack(request): if stack.is_valid(): stack.save() messages.success(request, _("The stack was created.")) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-stack")) return form( {"topoform": stack, "action_name": _("Add")}, "topologie/topo.html", request ) @@ -455,7 +481,7 @@ def edit_stack(request, stack, **_kwargs): if stack.changed_data: stack.save() messages.success(request, _("The stack was edited.")) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-stack")) return form( {"topoform": stack, "action_name": _("Edit")}, "topologie/topo.html", request ) @@ -480,7 +506,7 @@ def del_stack(request, stack, **_kwargs): % stack ), ) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-stack")) return form({"objet": stack}, "topologie/delete.html", request) @@ -847,7 +873,7 @@ def new_switch_bay(request): if switch_bay.is_valid(): switch_bay.save() messages.success(request, _("The switch bay was created.")) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-switch-bay")) return form( {"topoform": switch_bay, "action_name": _("Add")}, "topologie/topo.html", @@ -864,7 +890,7 @@ def edit_switch_bay(request, switch_bay, **_kwargs): if switch_bay.changed_data: switch_bay.save() messages.success(request, _("The switch bay was edited.")) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-switch-bay")) return form( {"topoform": switch_bay, "action_name": _("Edit")}, "topologie/topo.html", @@ -891,7 +917,7 @@ def del_switch_bay(request, switch_bay, **_kwargs): % switch_bay ), ) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-switch-bay")) return form( {"objet": switch_bay, "objet_name": _("switch bay")}, "topologie/delete.html", @@ -907,7 +933,7 @@ def new_building(request): if building.is_valid(): building.save() messages.success(request, _("The building was created.")) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-building")) return form( {"topoform": building, "action_name": _("Add")}, "topologie/topo.html", @@ -924,7 +950,7 @@ def edit_building(request, building, **_kwargs): if building.changed_data: building.save() messages.success(request, _("The building was edited.")) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-building")) return form( {"topoform": building, "action_name": _("Edit")}, "topologie/topo.html", request ) @@ -949,7 +975,7 @@ def del_building(request, building, **_kwargs): % building ), ) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-building")) return form( {"objet": building, "objet_name": _("building")}, "topologie/delete.html", @@ -965,7 +991,7 @@ def new_dormitory(request): if dormitory.is_valid(): dormitory.save() messages.success(request, _("The dormitory was created.")) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-dormitory")) return form( {"topoform": dormitory, "action_name": _("Add")}, "topologie/topo.html", @@ -982,7 +1008,7 @@ def edit_dormitory(request, dormitory, **_kwargs): if dormitory.changed_data: dormitory.save() messages.success(request, _("The dormitory was edited.")) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-dormitory")) return form( {"topoform": dormitory, "action_name": _("Edit")}, "topologie/topo.html", @@ -1009,7 +1035,7 @@ def del_dormitory(request, dormitory, **_kwargs): % dormitory ), ) - return redirect(reverse("topologie:index-physical-grouping")) + return redirect(reverse("topologie:index-dormitory")) return form( {"objet": dormitory, "objet_name": _("dormitory")}, "topologie/delete.html", diff --git a/users/templates/users/sidebar.html b/users/templates/users/sidebar.html index d2ee77ff..54d83af3 100644 --- a/users/templates/users/sidebar.html +++ b/users/templates/users/sidebar.html @@ -26,73 +26,5 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load i18n %} {% block sidebar %} - {% if request.user.is_authenticated%} - {% can_create Club %} - - - {% trans "Create a club or organisation" %} - - {% acl_end %} - {% can_create Adherent %} - - - {% trans "Create a user" %} - - {% acl_end %} - {% endif %} - {% can_view_all Club %} - - - {% trans "Clubs and organisations" %} - - {% acl_end %} - {% can_view_all Adherent %} - - - {% trans "Users" %} - - {% acl_end %} - {% can_view_all Ban %} - - - {% trans "Bans" %} - - {% acl_end %} - {% can_view_all Whitelist %} - - - {% trans "Whitelists" %} - - {% acl_end %} - {% can_view_all School %} - - - {% trans "Schools" %} - - {% acl_end %} - {% can_view_all ListShell %} - - - {% trans "Shells" %} - - {% acl_end %} - {% can_view_all ListRight %} - - - {% trans "Groups of rights" %} - - {% acl_end %} - {% can_view_all ServiceUser %} - - - {% trans "Service users" %} - - {% acl_end %} - {% can_change User state %} - - - {% trans "Massively archive" %} - - {% acl_end %} {% endblock %}