diff --git a/users/admin.py b/users/admin.py index e7dd3240..15cba77f 100644 --- a/users/admin.py +++ b/users/admin.py @@ -32,6 +32,8 @@ from django.contrib.auth.models import Group from django.contrib.auth.admin import UserAdmin as BaseUserAdmin from reversion.admin import VersionAdmin +from re2o.admin import user_admin_site + from .models import ( User, EMailAddress, @@ -216,6 +218,7 @@ admin.site.register(LdapUserGroup, LdapUserGroupAdmin) admin.site.register(LdapServiceUser, LdapServiceUserAdmin) admin.site.register(LdapServiceUserGroup, LdapServiceUserGroupAdmin) admin.site.register(School, SchoolAdmin) +user_admin_site.register(School, SchoolAdmin) admin.site.register(ListRight, ListRightAdmin) admin.site.register(ListShell, ListShellAdmin) admin.site.register(Ban, BanAdmin) diff --git a/users/templates/users/index_schools.html b/users/templates/users/index_schools.html deleted file mode 100644 index e27f63a9..00000000 --- a/users/templates/users/index_schools.html +++ /dev/null @@ -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 %} -

{% trans "List of schools" %}

-
{% trans "List of schools for created users" %}
- {% can_create School %} - {% trans " Add a school" %} - {% acl_end %} - {% trans " Delete one or several schools" %} -
- {% include 'users/aff_schools.html' with school_list=school_list %} -
-
-
-{% endblock %} - diff --git a/users/templates/users/sidebar.html b/users/templates/users/sidebar.html index 7a7daae3..0fb6efa0 100644 --- a/users/templates/users/sidebar.html +++ b/users/templates/users/sidebar.html @@ -65,7 +65,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% acl_end %} {% can_view_all School %} - + {% trans "Schools" %} diff --git a/users/urls.py b/users/urls.py index 1e6ffa8c..38e14f3c 100644 --- a/users/urls.py +++ b/users/urls.py @@ -77,11 +77,6 @@ urlpatterns = [ url(r'^edit_email_settings/(?P[0-9]+)$', views.edit_email_settings, name='edit-email-settings'), - url(r'^add_school/$', views.add_school, name='add-school'), - url(r'^edit_school/(?P[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'^edit_listright/(?P[0-9]+)$', views.edit_listright, @@ -97,7 +92,6 @@ urlpatterns = [ url(r'^profil/(?P[0-9]+)$', views.profil, name='profil'), url(r'^index_ban/$', views.index_ban, name='index-ban'), 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_listright/$', views.index_listright, name='index-listright'), url(r'^index_serviceusers/$', diff --git a/users/views.py b/users/views.py index ea22359a..908a22ca 100644 --- a/users/views.py +++ b/users/views.py @@ -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 @can_create(ListShell) def add_shell(request):