From 403fb85656f342fefa3e929d5c47c457cd1e3880 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 26 Feb 2019 10:03:48 +0100 Subject: [PATCH] Use user admin for shells management --- users/admin.py | 1 + users/templates/users/index_shell.html | 42 ------------------ users/templates/users/sidebar.html | 2 +- users/urls.py | 8 ---- users/views.py | 60 -------------------------- 5 files changed, 2 insertions(+), 111 deletions(-) delete mode 100644 users/templates/users/index_shell.html diff --git a/users/admin.py b/users/admin.py index a92c4004..98b949b2 100644 --- a/users/admin.py +++ b/users/admin.py @@ -221,6 +221,7 @@ admin.site.register(School, SchoolAdmin) user_admin_site.register(School, SchoolAdmin) admin.site.register(ListRight, ListRightAdmin) admin.site.register(ListShell, ListShellAdmin) +user_admin_site.register(ListShell, ListShellAdmin) admin.site.register(Ban, BanAdmin) admin.site.register(EMailAddress, EMailAddressAdmin) admin.site.register(Whitelist, WhitelistAdmin) diff --git a/users/templates/users/index_shell.html b/users/templates/users/index_shell.html deleted file mode 100644 index 9d75fdd8..00000000 --- a/users/templates/users/index_shell.html +++ /dev/null @@ -1,42 +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 shells" %}

- {% can_create ListShell %} - {% trans " Add a shell" %} - {% acl_end %} - {% include 'users/aff_shell.html' with shell_list=shell_list %} -
-
-
-{% endblock %} - diff --git a/users/templates/users/sidebar.html b/users/templates/users/sidebar.html index 0fb6efa0..850a95da 100644 --- a/users/templates/users/sidebar.html +++ b/users/templates/users/sidebar.html @@ -71,7 +71,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% acl_end %} {% can_view_all ListShell %} - + {% trans "Shells" %} diff --git a/users/urls.py b/users/urls.py index 38e14f3c..b3238d13 100644 --- a/users/urls.py +++ b/users/urls.py @@ -82,17 +82,9 @@ urlpatterns = [ views.edit_listright, name='edit-listright'), url(r'^del_listright/$', views.del_listright, name='del-listright'), - url(r'^add_shell/$', views.add_shell, name='add-shell'), - url(r'^edit_shell/(?P[0-9]+)$', - views.edit_shell, - name='edit-shell'), - url(r'^del_shell/(?P[0-9]+)$', - views.del_shell, - name='del-shell'), 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_shell/$', views.index_shell, name='index-shell'), url(r'^index_listright/$', views.index_listright, name='index-listright'), url(r'^index_serviceusers/$', views.index_serviceusers, diff --git a/users/views.py b/users/views.py index 908a22ca..d15a5568 100644 --- a/users/views.py +++ b/users/views.py @@ -597,54 +597,6 @@ def edit_email_settings(request, user_instance, **_kwargs): ) -@login_required -@can_create(ListShell) -def add_shell(request): - """ Ajouter un shell à la base de donnée""" - shell = ShellForm(request.POST or None) - if shell.is_valid(): - shell.save() - messages.success(request, _("The shell was added.")) - return redirect(reverse('users:index-shell')) - return form( - {'userform': shell, 'action_name': _("Add a shell")}, - 'users/user.html', - request - ) - - -@login_required -@can_edit(ListShell) -def edit_shell(request, shell_instance, **_kwargs): - """ Editer un shell à partir du listshellid""" - shell = ShellForm(request.POST or None, instance=shell_instance) - if shell.is_valid(): - if shell.changed_data: - shell.save() - messages.success(request, _("The shell was edited.")) - return redirect(reverse('users:index-shell')) - return form( - {'userform': shell, 'action_name': _("Edit a shell")}, - 'users/user.html', - request - ) - - -@login_required -@can_delete(ListShell) -def del_shell(request, shell, **_kwargs): - """Destruction d'un shell""" - if request.method == "POST": - shell.delete() - messages.success(request, _("The shell was deleted.")) - return redirect(reverse('users:index-shell')) - return form( - {'objet': shell, 'objet_name': 'shell'}, - 'users/delete.html', - request - ) - - @login_required @can_create(ListRight) def add_listright(request): @@ -831,18 +783,6 @@ def index_school(request): ) -@login_required -@can_view_all(ListShell) -def index_shell(request): - """ Affiche l'ensemble des shells""" - shell_list = ListShell.objects.order_by('shell') - return render( - request, - 'users/index_shell.html', - {'shell_list': shell_list} - ) - - @login_required @can_view_all(ListRight) def index_listright(request):