mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-28 15:42:25 +00:00
Switch schools management page to user admin site
This commit is contained in:
parent
eca74aae6b
commit
e38a661680
5 changed files with 4 additions and 114 deletions
|
@ -32,6 +32,8 @@ from django.contrib.auth.models import Group
|
||||||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||||
from reversion.admin import VersionAdmin
|
from reversion.admin import VersionAdmin
|
||||||
|
|
||||||
|
from re2o.admin import user_admin_site
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
User,
|
User,
|
||||||
EMailAddress,
|
EMailAddress,
|
||||||
|
@ -216,6 +218,7 @@ admin.site.register(LdapUserGroup, LdapUserGroupAdmin)
|
||||||
admin.site.register(LdapServiceUser, LdapServiceUserAdmin)
|
admin.site.register(LdapServiceUser, LdapServiceUserAdmin)
|
||||||
admin.site.register(LdapServiceUserGroup, LdapServiceUserGroupAdmin)
|
admin.site.register(LdapServiceUserGroup, LdapServiceUserGroupAdmin)
|
||||||
admin.site.register(School, SchoolAdmin)
|
admin.site.register(School, SchoolAdmin)
|
||||||
|
user_admin_site.register(School, SchoolAdmin)
|
||||||
admin.site.register(ListRight, ListRightAdmin)
|
admin.site.register(ListRight, ListRightAdmin)
|
||||||
admin.site.register(ListShell, ListShellAdmin)
|
admin.site.register(ListShell, ListShellAdmin)
|
||||||
admin.site.register(Ban, BanAdmin)
|
admin.site.register(Ban, BanAdmin)
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
{% 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 acl %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block title %}{% trans "Users" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h2>{% trans "List of schools" %}</h2>
|
|
||||||
<h5>{% trans "List of schools for created users" %}</h5>
|
|
||||||
{% can_create School %}
|
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-school' %}"><i class="fa fa-plus"></i>{% trans " Add a school" %}</a>
|
|
||||||
{% acl_end %}
|
|
||||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'users:del-school' %}"><i class="fa fa-trash"></i>{% trans " Delete one or several schools" %}</a>
|
|
||||||
<hr>
|
|
||||||
{% include 'users/aff_schools.html' with school_list=school_list %}
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</a>
|
</a>
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
{% can_view_all School %}
|
{% can_view_all School %}
|
||||||
<a class="list-group-item list-group-item-info" href="{% url 'users:index-school' %}">
|
<a class="list-group-item list-group-item-info" href="{% url 'user_admin:users_school_changelist' %}">
|
||||||
<i class="fa fa-list-ul"></i>
|
<i class="fa fa-list-ul"></i>
|
||||||
{% trans "Schools" %}
|
{% trans "Schools" %}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -77,11 +77,6 @@ urlpatterns = [
|
||||||
url(r'^edit_email_settings/(?P<userid>[0-9]+)$',
|
url(r'^edit_email_settings/(?P<userid>[0-9]+)$',
|
||||||
views.edit_email_settings,
|
views.edit_email_settings,
|
||||||
name='edit-email-settings'),
|
name='edit-email-settings'),
|
||||||
url(r'^add_school/$', views.add_school, name='add-school'),
|
|
||||||
url(r'^edit_school/(?P<schoolid>[0-9]+)$',
|
|
||||||
views.edit_school,
|
|
||||||
name='edit-school'),
|
|
||||||
url(r'^del_school/$', views.del_school, name='del-school'),
|
|
||||||
url(r'^add_listright/$', views.add_listright, name='add-listright'),
|
url(r'^add_listright/$', views.add_listright, name='add-listright'),
|
||||||
url(r'^edit_listright/(?P<listrightid>[0-9]+)$',
|
url(r'^edit_listright/(?P<listrightid>[0-9]+)$',
|
||||||
views.edit_listright,
|
views.edit_listright,
|
||||||
|
@ -97,7 +92,6 @@ urlpatterns = [
|
||||||
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'),
|
||||||
url(r'^index_school/$', views.index_school, name='index-school'),
|
|
||||||
url(r'^index_shell/$', views.index_shell, name='index-shell'),
|
url(r'^index_shell/$', views.index_shell, name='index-shell'),
|
||||||
url(r'^index_listright/$', views.index_listright, name='index-listright'),
|
url(r'^index_listright/$', views.index_listright, name='index-listright'),
|
||||||
url(r'^index_serviceusers/$',
|
url(r'^index_serviceusers/$',
|
||||||
|
|
|
@ -597,68 +597,6 @@ def edit_email_settings(request, user_instance, **_kwargs):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@can_create(School)
|
|
||||||
def add_school(request):
|
|
||||||
""" Ajouter un établissement d'enseignement à la base de donnée,
|
|
||||||
need cableur"""
|
|
||||||
school = SchoolForm(request.POST or None)
|
|
||||||
if school.is_valid():
|
|
||||||
school.save()
|
|
||||||
messages.success(request, _("The school was added."))
|
|
||||||
return redirect(reverse('users:index-school'))
|
|
||||||
return form(
|
|
||||||
{'userform': school, 'action_name': _("Add a school")},
|
|
||||||
'users/user.html',
|
|
||||||
request
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@can_edit(School)
|
|
||||||
def edit_school(request, school_instance, **_kwargs):
|
|
||||||
""" Editer un établissement d'enseignement à partir du schoolid dans
|
|
||||||
la base de donnée, need cableur"""
|
|
||||||
school = SchoolForm(request.POST or None, instance=school_instance)
|
|
||||||
if school.is_valid():
|
|
||||||
if school.changed_data:
|
|
||||||
school.save()
|
|
||||||
messages.success(request, _("The school was edited."))
|
|
||||||
return redirect(reverse('users:index-school'))
|
|
||||||
return form(
|
|
||||||
{'userform': school, 'action_name': _("Edit a school")},
|
|
||||||
'users/user.html',
|
|
||||||
request
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@can_delete_set(School)
|
|
||||||
def del_school(request, instances):
|
|
||||||
""" Supprimer un établissement d'enseignement à la base de donnée,
|
|
||||||
need cableur
|
|
||||||
Objet protégé, possible seulement si aucun user n'est affecté à
|
|
||||||
l'établissement """
|
|
||||||
school = DelSchoolForm(request.POST or None, instances=instances)
|
|
||||||
if school.is_valid():
|
|
||||||
school_dels = school.cleaned_data['schools']
|
|
||||||
for school_del in school_dels:
|
|
||||||
try:
|
|
||||||
school_del.delete()
|
|
||||||
messages.success(request, _("The school was deleted."))
|
|
||||||
except ProtectedError:
|
|
||||||
messages.error(
|
|
||||||
request,
|
|
||||||
_("The school %s is assigned to at least one user,"
|
|
||||||
" impossible to delete it.") % school_del)
|
|
||||||
return redirect(reverse('users:index-school'))
|
|
||||||
return form(
|
|
||||||
{'userform': school, 'action_name': _("Delete")},
|
|
||||||
'users/user.html',
|
|
||||||
request
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(ListShell)
|
@can_create(ListShell)
|
||||||
def add_shell(request):
|
def add_shell(request):
|
||||||
|
|
Loading…
Reference in a new issue