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..57205953 --- /dev/null +++ b/multi_op/templates/multi_op/aff_room_state.html @@ -0,0 +1,69 @@ +{% 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" %}
{{ 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.user.is_adherent %}{{ room.user.end_adhesion }}{% else %}{% trans "Not a member" %}{% endif %} + {% if room.user.has_access == True %} + {% trans "Active" %} + {% else %} + {% trans "Disabled" %} + {% 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..d5b6cb51 --- /dev/null +++ b/multi_op/templates/multi_op/navbar.html @@ -0,0 +1,2 @@ +{% load i18n %} +
  • {% trans "Tickets" %}
  • 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..0dbb0ca8 --- /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'^multi_op/edit-preferences-multiop$', views.edit_preferences, name='edit-preferences-multiop'), +] diff --git a/multi_op/views.py b/multi_op/views.py new file mode 100644 index 00000000..41c7e40d --- /dev/null +++ b/multi_op/views.py @@ -0,0 +1,179 @@ +# -*- 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} + ) + + +def edit_preferences(request): + """ View to edit the settings of the tickets """ + + preferences_instance, created = Preferences.objects.get_or_create(id=1) + preferencesform = EditPreferencesForm( + request.POST or None, + instance = preferences_instance,) + + if preferencesform.is_valid(): + if preferencesform.changed_data: + preferencesform.save() + messages.success(request,'Preferences updated') + return redirect(reverse('preferences:display-options',)) + else: + messages.error(request,'Formulaire Invalide') + return form({'preferencesform':preferencesform,},'multi_op/form_preferences.html',request) + return form({'preferencesform':preferencesform,},'multi_op/form_preferences.html',request) + + +def navbar_user(request): + """View to display the app in user's dropdown in the navbar""" + return render_to_string('multi_op/navbar.html') + +def navbar_logout(request): + """View to display the app in user's dropdown in the navbar""" + return None + + +def preferences(request): + """ View to display the settings of the tickets in the preferences page""" + pref, created = Preferences.objects.get_or_create(id=1) + context = {'preferences':pref,'language':str(pref.LANGUES[pref.mail_language][1])} + return render_to_string('tickets/preferences.html', context=context, request=request, using=None) + + 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'