mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-04 17:06:27 +00:00
Fix multi operators options edition
This commit is contained in:
parent
01e01de4c2
commit
6235bcbe53
12 changed files with 235 additions and 8 deletions
27
multi_op/migrations/0001_initial.py
Normal file
27
multi_op/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-09-04 12:50
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('topologie', '0074_auto_20200419_1640'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Preferences',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('enabled_dorm', models.ManyToManyField(blank=True, related_name='vlan_tagged', to='topologie.Dormitory', verbose_name='enabled dorm')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'dormitories preferences',
|
||||
},
|
||||
),
|
||||
]
|
19
multi_op/migrations/0002_auto_20200904_1905.py
Normal file
19
multi_op/migrations/0002_auto_20200904_1905.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-09-04 17:05
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('multi_op', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='Preferences',
|
||||
new_name='MultiopOption',
|
||||
),
|
||||
]
|
20
multi_op/migrations/0003_auto_20200904_1938.py
Normal file
20
multi_op/migrations/0003_auto_20200904_1938.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-09-04 17:38
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('multi_op', '0002_auto_20200904_1905'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='multiopoption',
|
||||
name='enabled_dorm',
|
||||
field=models.ManyToManyField(blank=True, related_name='enabled_dorm_multiop', to='topologie.Dormitory', verbose_name='enabled dorm'),
|
||||
),
|
||||
]
|
0
multi_op/migrations/__init__.py
Normal file
0
multi_op/migrations/__init__.py
Normal file
45
multi_op/models.py
Normal file
45
multi_op/models.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
# -*- 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 Arthur Grisel-Davy
|
||||
# Copyright © 2020 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.
|
||||
"""
|
||||
Multi_op model
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.template import loader
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
from reversion.models import Version
|
||||
|
||||
from re2o.mixins import AclMixin
|
||||
from re2o.mail_utils import send_mail_object
|
||||
from django.core.mail import EmailMessage
|
||||
|
||||
from preferences.models import GeneralOption
|
||||
|
||||
import users.models
|
||||
|
||||
from .preferences.models import MultiopOption
|
24
multi_op/preferences/__init__.py
Normal file
24
multi_op/preferences/__init__.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# -*- 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 © 2020 Gabriel Détraz
|
||||
# Copyright © 2019 Arthur Grisel-Davy
|
||||
#
|
||||
# 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.
|
||||
"""multi_op
|
||||
The app in charge of managing the operator of the dormitories
|
||||
"""
|
|
@ -30,12 +30,12 @@ from django import forms
|
|||
from django.forms import ModelForm, Form
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .models import Preferences
|
||||
from .models import MultiopOption
|
||||
|
||||
|
||||
class EditPreferencesForm(ModelForm):
|
||||
class EditMultiopOptionForm(ModelForm):
|
||||
"""Form used to edit the settings of multi_op."""
|
||||
|
||||
class Meta:
|
||||
model = Preferences
|
||||
model = MultiopOption
|
||||
fields = "__all__"
|
||||
|
|
|
@ -27,13 +27,16 @@ with multiple operators.
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from re2o.mixins import AclMixin, RevMixin
|
||||
from preferences.models import PreferencesModel
|
||||
|
||||
class Preferences(models.Model):
|
||||
|
||||
class MultiopOption(AclMixin, PreferencesModel):
|
||||
"""Definition of the settings of multi_op."""
|
||||
|
||||
enabled_dorm = models.ManyToManyField(
|
||||
"topologie.Dormitory",
|
||||
related_name="vlan_tagged",
|
||||
related_name="enabled_dorm_multiop",
|
||||
blank=True,
|
||||
verbose_name=_("enabled dorm"),
|
||||
)
|
||||
|
|
58
multi_op/preferences/views.py
Normal file
58
multi_op/preferences/views.py
Normal file
|
@ -0,0 +1,58 @@
|
|||
# -*- 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 © 2020 Gabriel Détraz
|
||||
# Copyright © 2019 Arthur Grisel-Davy
|
||||
#
|
||||
# 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
|
||||
# Lara 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.utils.translation import ugettext as _
|
||||
from django.urls import reverse
|
||||
|
||||
from re2o.base import re2o_paginator
|
||||
|
||||
from re2o.acl import can_view, can_view_all, can_edit, can_create
|
||||
|
||||
from preferences.views import edit_options_template_function
|
||||
|
||||
from . import forms
|
||||
from . import models
|
||||
|
||||
|
||||
|
||||
def aff_preferences(request):
|
||||
"""View used to display the settings of multi_op in the preferences page."""
|
||||
pref, created = models.MultiopOption.objects.get_or_create()
|
||||
context = {
|
||||
"preferences": pref,
|
||||
}
|
||||
return render_to_string(
|
||||
"multi_op/preferences.html", context=context, request=request, using=None
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
def edit_options(request, section):
|
||||
return edit_options_template_function(request, section, forms, models)
|
27
multi_op/templates/multi_op/preferences.html
Normal file
27
multi_op/templates/multi_op/preferences.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% load design %}
|
||||
{% load i18n %}
|
||||
|
||||
<div class="panel panel-default" id="multiop">
|
||||
<div class="panel-heading" data-toggle="collapse" href="#collapse_multiop">
|
||||
<h4 class="panel-title">
|
||||
<a><i class="fa fa-plug"></i> {% trans "Multi Op" %}</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<div id="collapse_multiop" class="panel-collapse panel-body collapse">
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'multi_op:edit-options' 'MultiopOption' %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
{% trans "Edit" %}
|
||||
</a>
|
||||
<p></p>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th><p>{% trans "Enabled Dorm" %}</p></th>
|
||||
<td><p>{{ preferences.enabled_dorm.all|join:", " }}</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -28,6 +28,7 @@ each.
|
|||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
from .preferences.views import edit_options
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^$", views.aff_state_global, name="aff-state-global"),
|
||||
|
@ -36,6 +37,11 @@ urlpatterns = [
|
|||
views.aff_state_dormitory,
|
||||
name="aff-state-dormitory",
|
||||
),
|
||||
url(
|
||||
r"^edit_options/(?P<section>MultiopOption)$",
|
||||
edit_options,
|
||||
name="edit-options",
|
||||
),
|
||||
url(
|
||||
r"^pending-connection$",
|
||||
views.aff_pending_connection,
|
||||
|
|
|
@ -45,12 +45,10 @@ from preferences.models import GeneralOption, AssoOption
|
|||
|
||||
from .forms import DormitoryForm
|
||||
|
||||
from .preferences.models import Preferences
|
||||
from .preferences.models import MultiopOption
|
||||
|
||||
from topologie.models import Room, Dormitory
|
||||
|
||||
from .preferences.forms import EditPreferencesForm
|
||||
|
||||
|
||||
def display_rooms_connection(request, dormitory=None):
|
||||
"""View used to display an overview of the rooms' connection state.
|
||||
|
|
Loading…
Reference in a new issue