mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-25 00:13:45 +00:00
Vue pour gérer la liste des écoles
This commit is contained in:
parent
e9d7071332
commit
387515d410
8 changed files with 129 additions and 2 deletions
19
topologie/migrations/0013_port_related.py
Normal file
19
topologie/migrations/0013_port_related.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('topologie', '0012_port_machine_interface'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='port',
|
||||||
|
name='related',
|
||||||
|
field=models.OneToOneField(null=True, to='topologie.Port', blank=True, related_name='related_port'),
|
||||||
|
),
|
||||||
|
]
|
26
topologie/migrations/0014_auto_20160706_1238.py
Normal file
26
topologie/migrations/0014_auto_20160706_1238.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('topologie', '0013_port_related'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name='port',
|
||||||
|
unique_together=set([('switch', 'port')]),
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='port',
|
||||||
|
name='_content_type',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='port',
|
||||||
|
name='_object_id',
|
||||||
|
),
|
||||||
|
]
|
23
topologie/migrations/0015_auto_20160706_1452.py
Normal file
23
topologie/migrations/0015_auto_20160706_1452.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('topologie', '0014_auto_20160706_1238'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='port',
|
||||||
|
name='related',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='port',
|
||||||
|
name='related',
|
||||||
|
field=models.ManyToManyField(related_name='_port_related_+', to='topologie.Port', blank=True),
|
||||||
|
),
|
||||||
|
]
|
23
topologie/migrations/0016_auto_20160706_1531.py
Normal file
23
topologie/migrations/0016_auto_20160706_1531.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('topologie', '0015_auto_20160706_1452'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='port',
|
||||||
|
name='related',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='port',
|
||||||
|
name='related',
|
||||||
|
field=models.OneToOneField(blank=True, to='topologie.Port', related_name='related_port', null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -131,6 +131,17 @@ class SchoolForm(ModelForm):
|
||||||
model = School
|
model = School
|
||||||
fields = ['name']
|
fields = ['name']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(SchoolForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['name'].label = 'Établissement à ajouter'
|
||||||
|
|
||||||
|
class DelSchoolForm(ModelForm):
|
||||||
|
schools = forms.ModelMultipleChoiceField(queryset=School.objects.all(), label="Etablissements actuels", widget=forms.CheckboxSelectMultiple)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
exclude = ['name']
|
||||||
|
model = School
|
||||||
|
|
||||||
class RightForm(ModelForm):
|
class RightForm(ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(RightForm, self).__init__(*args, **kwargs)
|
super(RightForm, self).__init__(*args, **kwargs)
|
||||||
|
|
|
@ -5,5 +5,7 @@
|
||||||
<p><a href="{% url "users:index" %}">Liste des adhérents</a></p>
|
<p><a href="{% url "users:index" %}">Liste des adhérents</a></p>
|
||||||
<p><a href="{% url "users:index-ban" %}">Liste des bannissements</a></p>
|
<p><a href="{% url "users:index-ban" %}">Liste des bannissements</a></p>
|
||||||
<p><a href="{% url "users:index-white" %}">Liste des accès à titre gracieux</a></p>
|
<p><a href="{% url "users:index-white" %}">Liste des accès à titre gracieux</a></p>
|
||||||
|
<p><a href="{% url "users:add-school" %}">Ajouter un établissement</a></p>
|
||||||
|
<p><a href="{% url "users:del-school" %}">Supprimer un établissement</a></p>
|
||||||
<p><a href="{% url "users:del-right" %}">Retirer un droit rezo</a></p>
|
<p><a href="{% url "users:del-right" %}">Retirer un droit rezo</a></p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -13,6 +13,8 @@ urlpatterns = [
|
||||||
url(r'^edit_whitelist/(?P<whitelistid>[0-9]+)$', views.edit_whitelist, name='edit-whitelist'),
|
url(r'^edit_whitelist/(?P<whitelistid>[0-9]+)$', views.edit_whitelist, name='edit-whitelist'),
|
||||||
url(r'^add_right/(?P<userid>[0-9]+)$', views.add_right, name='add-right'),
|
url(r'^add_right/(?P<userid>[0-9]+)$', views.add_right, name='add-right'),
|
||||||
url(r'^del_right/$', views.del_right, name='del-right'),
|
url(r'^del_right/$', views.del_right, name='del-right'),
|
||||||
|
url(r'^add_school/$', views.add_school, name='add-school'),
|
||||||
|
url(r'^del_school/$', views.del_school, name='del-school'),
|
||||||
url(r'^profil/(?P<userid>[0-9]+)$', views.profil, name='profil'),
|
url(r'^profil/(?P<userid>[0-9]+)$', views.profil, name='profil'),
|
||||||
url(r'^index_ban/$', views.index_ban, name='index-ban'),
|
url(r'^index_ban/$', views.index_ban, name='index-ban'),
|
||||||
url(r'^index_white/$', views.index_white, name='index-white'),
|
url(r'^index_white/$', views.index_white, name='index-white'),
|
||||||
|
|
|
@ -6,11 +6,11 @@ from django.shortcuts import render_to_response, get_object_or_404
|
||||||
from django.core.context_processors import csrf
|
from django.core.context_processors import csrf
|
||||||
from django.template import Context, RequestContext, loader
|
from django.template import Context, RequestContext, loader
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.db.models import Max
|
from django.db.models import Max, ProtectedError
|
||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from users.models import User, Right, Ban, DelRightForm, UserForm, InfoForm, PasswordForm, StateForm, RightForm, BanForm, ProfilForm, Whitelist, WhitelistForm
|
from users.models import User, Right, Ban, DelRightForm, UserForm, InfoForm, PasswordForm, StateForm, RightForm, BanForm, ProfilForm, Whitelist, WhitelistForm, DelSchoolForm, SchoolForm
|
||||||
from cotisations.models import Facture
|
from cotisations.models import Facture
|
||||||
from machines.models import Machine, Interface
|
from machines.models import Machine, Interface
|
||||||
from users.forms import PassForm
|
from users.forms import PassForm
|
||||||
|
@ -217,6 +217,27 @@ def edit_whitelist(request, whitelistid):
|
||||||
return redirect("/users/")
|
return redirect("/users/")
|
||||||
return form({'userform': whitelist}, 'users/user.html', request)
|
return form({'userform': whitelist}, 'users/user.html', request)
|
||||||
|
|
||||||
|
def add_school(request):
|
||||||
|
school = SchoolForm(request.POST or None)
|
||||||
|
if school.is_valid():
|
||||||
|
school.save()
|
||||||
|
messages.success(request, "L'établissement a été ajouté")
|
||||||
|
return redirect("/users/")
|
||||||
|
return form({'userform': school}, 'users/user.html', request)
|
||||||
|
|
||||||
|
def del_school(request):
|
||||||
|
school = DelSchoolForm(request.POST or None)
|
||||||
|
if school.is_valid():
|
||||||
|
school_dels = school.cleaned_data['schools']
|
||||||
|
for school_del in school_dels:
|
||||||
|
try:
|
||||||
|
school_del.delete()
|
||||||
|
messages.success(request, "L'établissement a été supprimé")
|
||||||
|
except ProtectedError:
|
||||||
|
messages.error(request, "L'établissement %s est affecté à au moins un user, vous ne pouvez pas le supprimer" % school_del)
|
||||||
|
return redirect("/users/")
|
||||||
|
return form({'userform': school}, 'users/user.html', request)
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
users_list = User.objects.order_by('pk')
|
users_list = User.objects.order_by('pk')
|
||||||
connexion = []
|
connexion = []
|
||||||
|
|
Loading…
Reference in a new issue