diff --git a/multi_op/__init__.py b/multi_op/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/multi_op/apps.py b/multi_op/apps.py new file mode 100644 index 00000000..ae633793 --- /dev/null +++ b/multi_op/apps.py @@ -0,0 +1,33 @@ +# -*- mode: python; coding: utf-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 © 2019 Gabriel Détraz +# +# 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. +""" +The database models for the 'apps' app of re2o. + +For further details on each of those models, see the documentation details for +each. +""" + + +from django.apps import AppConfig + + +class MultiOpConfig(AppConfig): + name = 'multi_op' diff --git a/multi_op/forms.py b/multi_op/forms.py new file mode 100644 index 00000000..bedebb0a --- /dev/null +++ b/multi_op/forms.py @@ -0,0 +1,54 @@ +# -*- mode: python; coding: utf-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 Gabriel Détraz +# Copyright © 2017 Goulven Kermarec +# Copyright © 2017 Augustin Lemesle +# Copyright © 2017 Maël Kervella +# +# 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. +""" +Select a dorm +""" + + +from django import forms +from django.forms import ModelForm, Form +from re2o.field_permissions import FieldPermissionFormMixin +from re2o.mixins import FormRevMixin +from django.utils.translation import ugettext_lazy as _ + +from topologie.models import( + Dormitory, +) + + +class DormitoryForm(FormRevMixin, Form): + """Select a dorm""" + dormitory = forms.ModelMultipleChoiceField( + queryset=Dormitory.objects.all(), + label=_("Dormitory"), + widget=forms.CheckboxSelectMultiple, + required=False + ) + + def __init__(self, *args, **kwargs): + super(DormitoryForm, self).__init__(*args, **kwargs) + + + + diff --git a/multi_op/preferences/forms.py b/multi_op/preferences/forms.py new file mode 100644 index 00000000..d5e6ce80 --- /dev/null +++ b/multi_op/preferences/forms.py @@ -0,0 +1,39 @@ +# -*- mode: python; coding: utf-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 © 2019 Gabriel Détraz +# +# 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. +""" +The database models for the 'preference' app of re2o. + +For further details on each of those models, see the documentation details for +each. +""" + + +from django import forms +from django.forms import ModelForm, Form +from django.utils.translation import ugettext_lazy as _ + +from .models import Preferences + +class EditPreferencesForm(ModelForm): + """ Edit the ticket's settings""" + class Meta: + model = Preferences + fields = '__all__' diff --git a/multi_op/preferences/models.py b/multi_op/preferences/models.py new file mode 100644 index 00000000..89e82fb2 --- /dev/null +++ b/multi_op/preferences/models.py @@ -0,0 +1,40 @@ +# -*- mode: python; coding: utf-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 © 2019 Gabriel Détraz +# +# 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. +""" +Fichier définissant les administration des models de preference +""" + + +from django.db import models +from django.utils.translation import ugettext_lazy as _ + +class Preferences(models.Model): + """ Definition of the app settings""" + + enabled_dorm = models.ManyToManyField( + 'topologie.Dormitory', + related_name='vlan_tagged', + blank=True, + verbose_name=_("Enabled dorm") + ) + + class Meta: + verbose_name = _("Dormitory of connection settings") diff --git a/multi_op/templates/multi_op/aff_room_state.html b/multi_op/templates/multi_op/aff_room_state.html new file mode 100644 index 00000000..75ca027c --- /dev/null +++ b/multi_op/templates/multi_op/aff_room_state.html @@ -0,0 +1,75 @@ +{% 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 Goulven 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 acl %} +{% load logs_extra %} +{% load i18n %} + +{% if room_list.paginator %} + {% include 'pagination.html' with list=room_list %} +{% endif %} + + + + + {% trans "Room" as tr_room %} + {% trans "Building" as tr_building %} + + + + + + + + + + + {% for room in room_list %} + + + + + + + + + + + {% endfor %} +
{% include 'buttons/sort.html' with prefix='building' col='name' text=tr_building %}{% include 'buttons/sort.html' with prefix='room' col='name' text=tr_room %}{% trans "Connnected on" %}{% trans "User" %}{% trans "Details" %}{% trans "End of subscription on" %}{% trans "Internet access" %}{% trans "Action" %}
{{ room.building }}{{ room.name }}{% if room.port_set.all %}AURORE{% else %}{% trans "Other operator" %}{% endif %}{% if room.adherent %}{{ room.adherent }}{% else %} {% trans "Aucun" %}{% endif %}{{ room.details }}{% if room.adherent.is_adherent %}{% else %}{% endif %}{% if room.adherent.end_adhesion %}{{ room.adherent.end_adhesion}}{% else %}{% trans "No member" %}{% endif %} + {% if room.adherent.has_access == True %} + {% trans "Active" %} + {% else %} + {% trans "Disabled" %} + {% endif %} + + {% if room.port_set.all %} + + {% endif %} +
+ +{% if room_list.paginator %} + {% include 'pagination.html' with list=room_list %} +{% endif %} + diff --git a/multi_op/templates/multi_op/form_preferences.html b/multi_op/templates/multi_op/form_preferences.html new file mode 100644 index 00000000..5c7e5d5e --- /dev/null +++ b/multi_op/templates/multi_op/form_preferences.html @@ -0,0 +1,48 @@ +{% extends 'machines/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 Goulven Kermarec +Copyright © 2017 Augustin Lemesle +Copyright © 2017 Maël Kervella + +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 i18n %} + +{% block title %}{% trans "Ticket" %}{% endblock %} + +{% block content %} +

{% trans "Tickets settings modification" %}

+ +{% for message in messages %} +
+ + {{ message | safe }} +
+{% endfor %} + +
+ {% csrf_token %} + {% bootstrap_field preferencesform.publish_address %} + {% bootstrap_field preferencesform.mail_language %} + {% bootstrap_button "Editer" button_type="submit" icon='ok' button_class='btn-success' %} +
+{% endblock %} diff --git a/multi_op/templates/multi_op/form_ticket.html b/multi_op/templates/multi_op/form_ticket.html new file mode 100644 index 00000000..d35e9f5d --- /dev/null +++ b/multi_op/templates/multi_op/form_ticket.html @@ -0,0 +1,58 @@ +{% extends 'machines/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 Goulven Kermarec +Copyright © 2017 Augustin Lemesle +Copyright © 2017 Maël Kervella + +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 massive_bootstrap_form %} +{% load i18n %} + +{% block title %}{% trans "Ticket" %}{% endblock %} + +{% block content %} +

Ouverture d'un Ticket

+ +
+ {% csrf_token %} + {% if not user.is_authenticated %} +

{% trans "Vous n'êtes pas authentifié. Veuillez fournir une adresse mail afin que nous puissions vous recontacter." %}

+ {% bootstrap_field ticketform.email %} + {% endif %} + {% bootstrap_field ticketform.title %} +
+

{% trans "Description de votre problème. Veuillez fournir le plus d'informations possible afin de faciliter la recherche de solution. Voici quelques informations dont nous pourions avoir besoin:" %}

+ + {% bootstrap_field ticketform.description %} + {% bootstrap_button "Ouvrir le Ticket" button_type="submit" icon='ok' button_class='btn-success' %} +
+{% endblock %} diff --git a/multi_op/templates/multi_op/index.html b/multi_op/templates/multi_op/index.html new file mode 100644 index 00000000..4429c4fd --- /dev/null +++ b/multi_op/templates/multi_op/index.html @@ -0,0 +1,34 @@ +{% extends 'users/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 Goulven 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 i18n %} + +{% block title%}{% trans "Tickets" %}{% endblock %} + +{% block content %} +

{% trans "Tickets" %}

+ {% include 'tickets/aff_tickets.html' with tickets_list=tickets_list %} +{% endblock %} diff --git a/multi_op/templates/multi_op/index_room_state.html b/multi_op/templates/multi_op/index_room_state.html new file mode 100644 index 00000000..50881a19 --- /dev/null +++ b/multi_op/templates/multi_op/index_room_state.html @@ -0,0 +1,53 @@ +{% extends 'multi_op/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 Goulven 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 "Multi Operators" %}{% endblock %} + +{% block content %} + +{% if dormitory_form %} +{% bootstrap_form_errors dormitory_form %} +{% endif %} + +

{% trans "Rooms connections" %}

+ +{% if dormitory_form %} +
+ {% csrf_token %} + {% bootstrap_form dormitory_form %} + {% bootstrap_button "Select Dormitory" icon='ok' button_class='btn-success' %} +
+{% endif %} + +{% include 'multi_op/aff_room_state.html' with room_list=room_list %} +
+
+
+{% endblock %} + diff --git a/multi_op/templates/multi_op/navbar.html b/multi_op/templates/multi_op/navbar.html new file mode 100644 index 00000000..c5e84c43 --- /dev/null +++ b/multi_op/templates/multi_op/navbar.html @@ -0,0 +1,2 @@ +{% load i18n %} +
  • {% trans "Multi Operators" %}
  • diff --git a/multi_op/templates/multi_op/navbar_logout.html b/multi_op/templates/multi_op/navbar_logout.html new file mode 100644 index 00000000..8a7114f3 --- /dev/null +++ b/multi_op/templates/multi_op/navbar_logout.html @@ -0,0 +1,6 @@ +{% load i18n %} +
  • + + {% trans "Ouvrir un ticket" %} + +
  • diff --git a/multi_op/templates/multi_op/preferences.html b/multi_op/templates/multi_op/preferences.html new file mode 100644 index 00000000..60cbfac6 --- /dev/null +++ b/multi_op/templates/multi_op/preferences.html @@ -0,0 +1,36 @@ +{% load i18n %} + +
    +
    +

    + {% trans "Tickets" %} +

    +
    + +
    + + + + {% trans "Edit" %} + +

    + +
    + + + + {% if preferences.publish_address %} + + {% else %} + + {% endif %} + + + + +

    {% trans "Publication email address"%}

    {{ preferences.publish_address }}

    {% trans "Pas d'adresse, les tickets ne sont pas annoncés" %}

    {% trans "Email language" %}

    {{ language }}

    +
    +
    +
    +
    +
    diff --git a/multi_op/templates/multi_op/sidebar.html b/multi_op/templates/multi_op/sidebar.html new file mode 100644 index 00000000..0433fc61 --- /dev/null +++ b/multi_op/templates/multi_op/sidebar.html @@ -0,0 +1,43 @@ +{% extends 'base.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 Goulven 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 %} + +{% block sidebar %} + + + {% trans "Rooms connection state" %} + + + + {% trans "Sockets to connect" %} + + + + {% trans "Sockets to disconnect" %} + + +{% endblock %} + diff --git a/multi_op/tests.py b/multi_op/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/multi_op/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/multi_op/urls.py b/multi_op/urls.py new file mode 100644 index 00000000..866de712 --- /dev/null +++ b/multi_op/urls.py @@ -0,0 +1,38 @@ +# -*- mode: python; coding: utf-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 © 2019 Gabriel Détraz +# +# 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. +""" +The database models for the 'urls' app of re2o. + +For further details on each of those models, see the documentation details for +each. +""" + +from django.conf.urls import url + +from . import views + +urlpatterns = [ + url(r'^$', views.aff_state_global, name='aff-state-global'), + url(r'^(?P[0-9]+)$', views.aff_state_dormitory, name='aff-state-dormitory'), + url(r'^pending-connection$', views.aff_pending_connection, name='aff-pending-connection'), + url(r'^pending-disconnection$', views.aff_pending_disconnection, name='aff-pending-disconnection'), + url(r'^disconnect-room/(?P[0-9]+)$', views.disconnect_room, name='disconnect-room'), +] diff --git a/multi_op/views.py b/multi_op/views.py new file mode 100644 index 00000000..7debd02e --- /dev/null +++ b/multi_op/views.py @@ -0,0 +1,163 @@ +# -*- mode: python; coding: utf-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 Gabriel Détraz +# Copyright © 2017 Goulven 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. + +# App de gestion des users pour re2o +# Goulven Kermarec, Gabriel Détraz, Lemesle Augustin +# Gplv2 + +from django.contrib import messages +from django.contrib.auth.decorators import login_required +from django.shortcuts import render, redirect +from django.template.loader import render_to_string +from django.views.decorators.cache import cache_page +from django.utils.translation import ugettext as _ +from django.urls import reverse +from django.forms import modelformset_factory +from django.db.models import Q +from re2o.views import form +from re2o.utils import all_has_access, all_adherent + +from re2o.base import ( + re2o_paginator, + SortTable, +) + +from re2o.acl import( + can_view, + can_view_all, + can_edit, + can_create, +) + +from preferences.models import GeneralOption + +from .forms import DormitoryForm + +from .preferences.models import( + Preferences, +) + +from topologie.models import Room, Dormitory + +from .preferences.forms import ( + EditPreferencesForm, +) + + +def display_rooms_connection(request, dormitory=None): + """View to display global state of connection state""" + room_list = Room.objects.select_related('building__dormitory').order_by('building_dormitory', 'port') + if dormitory: + room_list = room_list.filter(building__dormitory=dormitory) + room_list = SortTable.sort( + room_list, + request.GET.get('col'), + request.GET.get('order'), + SortTable.TOPOLOGIE_INDEX_ROOM + ) + pagination_number = GeneralOption.get_cached_value('pagination_number') + room_list = re2o_paginator(request, room_list, pagination_number) + return render( + request, + 'multi_op/index_room_state.html', + {'room_list': room_list} + ) + + +@login_required +@can_view_all(Room) +def aff_state_global(request): + return display_rooms_connection(request) + + +@login_required +@can_view(Dormitory) +def aff_state_dormitory(request, dormitory, dormitoryid): + return display_rooms_connection(dormitory=dormitory) + + +@login_required +@can_view_all(Room) +def aff_pending_connection(request): + """Aff pending Rooms to connect on our network""" + room_list = Room.objects.select_related('building__dormitory').filter(port__isnull=True).filter(adherent__in=all_has_access()).order_by('building_dormitory', 'port') + dormitory_form = DormitoryForm(request.POST or None) + if dormitory_form.is_valid(): + room_list = room_list.filter(building__dormitory__in=dormitory_form.cleaned_data['dormitory']) + room_list = SortTable.sort( + room_list, + request.GET.get('col'), + request.GET.get('order'), + SortTable.TOPOLOGIE_INDEX_ROOM + ) + pagination_number = GeneralOption.get_cached_value('pagination_number') + room_list = re2o_paginator(request, room_list, pagination_number) + return render( + request, + 'multi_op/index_room_state.html', + {'room_list': room_list, 'dormitory_form': dormitory_form} + ) + + +@login_required +@can_view_all(Room) +def aff_pending_disconnection(request): + """Aff pending Rooms to disconnect from our network""" + room_list = Room.objects.select_related('building__dormitory').filter(port__isnull=False).exclude(Q(adherent__in=all_has_access()) | Q(adherent__in=all_adherent())).order_by('building_dormitory', 'port') + dormitory_form = DormitoryForm(request.POST or None) + if dormitory_form.is_valid(): + room_list = room_list.filter(building__dormitory__in=dormitory_form.cleaned_data['dormitory']) + room_list = SortTable.sort( + room_list, + request.GET.get('col'), + request.GET.get('order'), + SortTable.TOPOLOGIE_INDEX_ROOM + ) + pagination_number = GeneralOption.get_cached_value('pagination_number') + room_list = re2o_paginator(request, room_list, pagination_number) + return render( + request, + 'multi_op/index_room_state.html', + {'room_list': room_list, 'dormitory_form': dormitory_form} + ) + + +@login_required +@can_edit(Room) +def disconnect_room(request, room, roomid): + """Action of disconnecting a room""" + room.port_set.clear() + room.save() + messages.success(request,'Room %s disconnected' % room) + return redirect(reverse( + 'multi_op:aff-pending-disconnection' + )) + + +def navbar_user(): + """View to display the app in user's dropdown in the navbar""" + return ('topologie', render_to_string('multi_op/navbar.html')) + + + + diff --git a/preferences/views.py b/preferences/views.py index 9a5da84d..d27cdb4f 100644 --- a/preferences/views.py +++ b/preferences/views.py @@ -105,7 +105,7 @@ def display_options(request): document_template_list = DocumentTemplate.objects.order_by('name') optionnal_apps = [import_module(app) for app in OPTIONNAL_APPS_RE2O] - optionnal_templates_list = [app.views.preferences(request) for app in optionnal_apps] + optionnal_templates_list = [app.views.preferences(request) for app in optionnal_apps if hasattr(app.views, 'preferences')] return form({ 'useroptions': useroptions, diff --git a/re2o/context_processors.py b/re2o/context_processors.py index 3ee39073..97f2d4f8 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -62,8 +62,8 @@ def context_optionnal_apps(request): """Fonction de context pour générer la navbar en fonction des apps optionnels""" optionnal_apps = [import_module(app) for app in OPTIONNAL_APPS_RE2O] - optionnal_templates_navbar_user_list = [app.views.navbar_user(request) for app in optionnal_apps] - optionnal_templates_navbar_logout_list = [app.views.navbar_logout(request) for app in optionnal_apps] + optionnal_templates_navbar_user_list = [app.views.navbar_user() for app in optionnal_apps if hasattr(app.views, 'navbar_user')] + optionnal_templates_navbar_logout_list = [app.views.navbar_logout() for app in optionnal_apps if hasattr(app.views, 'navbar_logout')] return {'optionnal_templates_navbar_user_list':optionnal_templates_navbar_user_list, 'optionnal_templates_navbar_logout_list':optionnal_templates_navbar_logout_list} diff --git a/re2o/views.py b/re2o/views.py index 414416a7..d443a84c 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -116,7 +116,7 @@ def contact_page(request): address = MailContact.objects.all() optionnal_apps = [import_module(app) for app in OPTIONNAL_APPS_RE2O] - optionnal_templates_contact_list = [app.views.contact(request) for app in optionnal_apps] + optionnal_templates_contact_list = [app.views.contact(request) for app in optionnal_apps if hasattr(app.views, 'contact')] return render( request, diff --git a/templates/base.html b/templates/base.html index f116c2be..122c7c3a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -101,9 +101,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
  • {% trans "Manage the subscriptions" %}
  • {% acl_end %} - {% for template in optionnal_templates_navbar_user_list%} - {{ template }} - {% endfor %} + {% for app, template in optionnal_templates_navbar_user_list %} + {% if app != 'topologie' %} + {{ template }} + {% endif %} + {% endfor %} {% acl_end %} @@ -114,6 +116,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
  • {% trans "Switches" %}
  • {% trans "Access points" %}
  • {% trans "Rooms" %}
  • + {% for app, template in optionnal_templates_navbar_user_list %} + {% if app == 'topologie' %} + {{ template }} + {% endif %} + {% endfor %} {% acl_end %} diff --git a/tickets/templates/tickets/navbar.html b/tickets/templates/tickets/navbar.html index 3c4318f7..11473229 100644 --- a/tickets/templates/tickets/navbar.html +++ b/tickets/templates/tickets/navbar.html @@ -1,2 +1,2 @@ {% load i18n %} -
  • {% trans "Tickets" %}
  • +
  • {% trans "Tickets" %}
  • diff --git a/tickets/views.py b/tickets/views.py index 7fb96511..b16e4eea 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -186,12 +186,12 @@ def preferences(request): def contact(request): """View to display a contact address on the contact page used here to display a link to open a ticket""" - return render_to_string('tickets/contact.html') + return ('users', render_to_string('tickets/contact.html')) -def navbar_user(request): +def navbar_user(): """View to display the ticket link in thet user's dropdown in the navbar""" - return render_to_string('tickets/navbar.html') + return ('users', render_to_string('tickets/navbar.html')) -def navbar_logout(request): +def navbar_logout(): """View to display the ticket link to log out users""" return render_to_string('tickets/navbar_logout.html') diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index 00489017..bf3fd9e5 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -187,9 +187,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
    {% trans "Room" %}
    - {{ users.room }} {% can_view_all Port %}{% if users.room.port_set.all %} / - {{ users.room.port_set.all|join:", " }} {% endif %}{% acl_end %} -
    + {{ users.room }} {% if users.room.port_set.all %}{% can_view_all Port %}/ + {{ users.room.port_set.all|join:", " }} {% acl_else %} + {% trans "Connected" %}{% acl_end %} + {% else %}{% if users.room %}{% trans "Pending connection..." %}{% endif %} + {% endif %} +
    @@ -222,7 +225,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if users.end_adhesion != None %}
    {{ users.end_adhesion }}
    {% else %} -
    {% trans "Not a member" %}
    +
    {% trans "not a member" %}
    {% endif %}
    diff --git a/users/views.py b/users/views.py index 37c0ec88..9764fbe0 100644 --- a/users/views.py +++ b/users/views.py @@ -977,7 +977,7 @@ def profil(request, users, **_kwargs): ) optionnal_apps = [import_module(app) for app in OPTIONNAL_APPS_RE2O] - optionnal_templates_list = [app.views.profil(request,users) for app in optionnal_apps] + optionnal_templates_list = [app.views.profil(request,users) for app in optionnal_apps if hasattr(app.views, 'profil')] pagination_large_number = GeneralOption.get_cached_value( 'pagination_large_number'