8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-22 23:13:46 +00:00

Merge branch 'multi_op_app' into 'dev'

Multi op app

See merge request federez/re2o!451
This commit is contained in:
klafyvel 2019-10-01 22:47:43 +02:00
commit ff9f6e5cc2
25 changed files with 752 additions and 17 deletions

0
multi_op/__init__.py Normal file
View file

33
multi_op/apps.py Normal file
View file

@ -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'

54
multi_op/forms.py Normal file
View file

@ -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)

View file

@ -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__'

View file

@ -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")

View file

@ -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 %}
<table class="table table-striped">
<thead>
<tr>
{% trans "Room" as tr_room %}
{% trans "Building" as tr_building %}
<th>{% include 'buttons/sort.html' with prefix='building' col='name' text=tr_building %}</th>
<th>{% include 'buttons/sort.html' with prefix='room' col='name' text=tr_room %}</th>
<th>{% trans "Connnected on" %}</th>
<th>{% trans "User" %}</th>
<th>{% trans "Details" %}</th>
<th>{% trans "End of subscription on" %}</th>
<th>{% trans "Internet access" %}</th>
<th>{% trans "Action" %}</th>
</tr>
</thead>
{% for room in room_list %}
<tr>
<td>{{ room.building }}</td>
<td>{{ room.name }}</td>
<td>{% if room.port_set.all %}<span class="label label-success">AURORE{% else %}<span class="label label-danger">{% trans "Other operator" %}{% endif %}</span></td>
<td>{% if room.adherent %}<a href="{% url 'users:profil' room.adherent.id%}">{{ room.adherent }}</a>{% else %} {% trans "Aucun" %}{% endif %}</td>
<td>{{ room.details }}</td>
<td>{% if room.adherent.is_adherent %}<i class="text-success">{% else %}<i class="text-danger">{% endif %}{% if room.adherent.end_adhesion %}{{ room.adherent.end_adhesion}}{% else %}{% trans "No member" %}{% endif %}</i></td>
<td>
{% if room.adherent.has_access == True %}
<i class="text-success">{% trans "Active" %}</i>
{% else %}
<i class="text-danger">{% trans "Disabled" %}</i>
{% endif %}
</td>
<td>
{% if room.port_set.all %}
<a href="{% url 'multi_op:disconnect-room' room.id %}" class="btn btn-danger btn-sm" role="button"><i class="fa fa-expand"></i></a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% if room_list.paginator %}
{% include 'pagination.html' with list=room_list %}
{% endif %}

View file

@ -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 %}
<h2> {% trans "Tickets settings modification" %}</h2>
{% for message in messages %}
<div class="{{ message| bootstrap_message_classes }} alert-dismissable">
<button type="button" class="close" data_dismiss="alert" aria-hidden="true">&#125;</button>
{{ message | safe }}
</div>
{% endfor %}
<form class="form" method="post">
{% csrf_token %}
{% bootstrap_field preferencesform.publish_address %}
{% bootstrap_field preferencesform.mail_language %}
{% bootstrap_button "Editer" button_type="submit" icon='ok' button_class='btn-success' %}
</form>
{% endblock %}

View file

@ -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 %}
<h2> Ouverture d'un Ticket </h2>
<form class="form" method="post">
{% csrf_token %}
{% if not user.is_authenticated %}
<p>{% trans "Vous n'êtes pas authentifié. Veuillez fournir une adresse mail afin que nous puissions vous recontacter." %}</p>
{% bootstrap_field ticketform.email %}
{% endif %}
{% bootstrap_field ticketform.title %}
<br>
<p>{% 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:" %}</p>
<ul class="list">
<li>
<p> {% trans "Le type de votre problème (adhesion, connexion, paiement ou autre)." %}</p>
</li>
<li>
<p> {% trans "Les conditions dans lesquelles vous rencontrez le problème (Wifi/filaire, sur tout les apareils ou sur un seul. Est-ce une nouvelle machine ?" %}</p>
</li>
<li>
<p> {% trans "Les endroits dans lequels le problème survient (chez vous, dans une partie commune, dans un batiment en particulier)." %}</p>
</ul>
{% bootstrap_field ticketform.description %}
{% bootstrap_button "Ouvrir le Ticket" button_type="submit" icon='ok' button_class='btn-success' %}
</form>
{% endblock %}

View file

@ -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 %}
<h2>{% trans "Tickets" %}</h2>
{% include 'tickets/aff_tickets.html' with tickets_list=tickets_list %}
{% endblock %}

View file

@ -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 %}
<h2>{% trans "Rooms connections" %}</h2>
{% if dormitory_form %}
<form class="form" method="post">
{% csrf_token %}
{% bootstrap_form dormitory_form %}
{% bootstrap_button "Select Dormitory" icon='ok' button_class='btn-success' %}
</form>
{% endif %}
{% include 'multi_op/aff_room_state.html' with room_list=room_list %}
<br />
<br />
<br />
{% endblock %}

View file

@ -0,0 +1,2 @@
{% load i18n %}
<li><a href="{% url 'multi_op:aff-state-global' %}"><i class="fa fa-random"></i> {% trans "Multi Operators" %}</a></li>

View file

@ -0,0 +1,6 @@
{% load i18n %}
<li>
<a href="{% url 'tickets:new-ticket' %}">
<i class="fa fa-ticket"></i> {% trans "Ouvrir un ticket" %}
</a>
</li>

View file

@ -0,0 +1,36 @@
{% load i18n %}
<div class="panel panel-default" id="tickets">
<div class="panel-heading" data-toggle="collapse" href="#collapse_tickets">
<h4 class="panel-title">
<a><i class="fa fa-ticket"></i> {% trans "Tickets" %}</a>
</h4>
</div>
<div id="collapse_tickets" class="panel-collapse panel-body collapse">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'tickets:edit-preferences-tickets' %}">
<i class="fa fa-edit"></i>
{% trans "Edit" %}
</a>
<p></p>
<div class="table-responsive">
<table class="table">
<tr>
<th><p>{% trans "Publication email address"%}</p></th>
{% if preferences.publish_address %}
<td><p>{{ preferences.publish_address }}</p></td>
{% else %}
<td><p>{% trans "Pas d'adresse, les tickets ne sont pas annoncés" %}</p></td>
{% endif %}
</tr>
<tr>
<th><p>{% trans "Email language" %}</p></th>
<td><p>{{ language }}</p></th>
</tr>
<table class="table">
</table>
</div>
</div>
</div>

View file

@ -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 %}
<a class="list-group-item list-group-item-info" href="{% url 'multi_op:aff-state-global' %}">
<i class="fa fa-random"></i>
{% trans "Rooms connection state" %}
</a>
<a class="list-group-item list-group-item-info" href="{% url 'multi_op:aff-pending-connection' %}">
<i class="fa fa-compress"></i>
{% trans "Sockets to connect" %}
</a>
<a class="list-group-item list-group-item-info" href="{% url 'multi_op:aff-pending-disconnection' %}">
<i class="fa fa-expand"></i>
{% trans "Sockets to disconnect" %}
</a>
{% endblock %}

3
multi_op/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

38
multi_op/urls.py Normal file
View file

@ -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<dormitoryid>[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<roomid>[0-9]+)$', views.disconnect_room, name='disconnect-room'),
]

163
multi_op/views.py Normal file
View file

@ -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'))

View file

@ -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,

View file

@ -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}

View file

@ -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,

View file

@ -101,9 +101,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<li><a href="{% url 'cotisations:index' %}"><i class="fa fa-eur"></i> {% trans "Manage the subscriptions" %}</a></li>
{% 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 %}
</ul>
</li>
{% acl_end %}
@ -114,6 +116,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<li><a href="{% url 'topologie:index' %}"><i class="fa fa-microchip"></i> {% trans "Switches" %}</a></li>
<li><a href="{% url 'topologie:index-ap' %}"><i class="fa fa-wifi"></i> {% trans "Access points" %}</a></li>
<li><a href="{% url 'topologie:index-room' %}"><i class="fa fa-home"></i> {% trans "Rooms" %}</a></li>
{% for app, template in optionnal_templates_navbar_user_list %}
{% if app == 'topologie' %}
{{ template }}
{% endif %}
{% endfor %}
</ul>
</li>
{% acl_end %}

View file

@ -1,2 +1,2 @@
{% load i18n %}
<li><a href="{% url 'tickets:aff-tickets' %}"><i class="fa fa-ticket"></i>{% trans "Tickets" %}</a></li>
<li><a href="{% url 'tickets:aff-tickets' %}"><i class="fa fa-ticket"></i> {% trans "Tickets" %}</a></li>

View file

@ -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')

View file

@ -187,9 +187,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<div class="col-md-6">
<dt>{% trans "Room" %}</dt>
<dd>
{{ users.room }} {% can_view_all Port %}{% if users.room.port_set.all %} /
{{ users.room.port_set.all|join:", " }} {% endif %}{% acl_end %}
</dd>
{{ users.room }} {% if users.room.port_set.all %}{% can_view_all Port %}/
{{ users.room.port_set.all|join:", " }} {% acl_else %}
<i class="text-success">{% trans "Connected" %}</i>{% acl_end %}
{% else %}{% if users.room %}<i class="text-danger">{% trans "Pending connection..." %}</i>{% endif %}
{% endif %}
</dd>
</div>
<div class="col-md-6">
@ -222,7 +225,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if users.end_adhesion != None %}
<dd><i class="text-success">{{ users.end_adhesion }}</i></dd>
{% else %}
<dd><i class="text-danger">{% trans "Not a member" %}</i></dd>
<dd><i class="text-danger">{% trans "not a member" %}</i></dd>
{% endif %}
</div>

View file

@ -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'