mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 15:12:25 +00:00
Merge branch 'edit_shell' into 'master'
Edit shell See merge request nounous/re2o!7
This commit is contained in:
commit
40c1d078a4
15 changed files with 437 additions and 5 deletions
110
logs/templates/logs/aff_stats_droits.html
Normal file
110
logs/templates/logs/aff_stats_droits.html
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
{% 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 %}
|
||||||
|
|
||||||
|
<div class="panel-group" id="accordion">
|
||||||
|
{% for droit in stats_list %}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading clearfix" data-parent="#accordion" data-toggle="collapse" data-target="#collapse{{droit.id}}">
|
||||||
|
<h2 class="panel-title pull-left">
|
||||||
|
<i class="fa fa-address-book"></i>
|
||||||
|
{{droit}}
|
||||||
|
<span class="badge">{{droit.user_set.all.count}}</span>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="panel-collapse collapse" id="collapse{{droit.id}}">
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Pseudo</th>
|
||||||
|
<th>Adhésion</th>
|
||||||
|
<th>Derniere connection</th>
|
||||||
|
<th>Nombre d'actions</th>
|
||||||
|
<th>Supprimer </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for user in droit.user_set.all %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ user.pseudo }}</td>
|
||||||
|
{% if user.is_adherent %}
|
||||||
|
<td><p class="text-success">Adhérent</p></td>
|
||||||
|
{% elif not user.end_adhesion %}
|
||||||
|
<td><p class="text-danger">On ne s'en souvient plus...</p></td>
|
||||||
|
{% else %}
|
||||||
|
<td><p class="text-danger">Plus depuis {{ user.end_adhesion }}</p></td>
|
||||||
|
{% endif %}
|
||||||
|
<td>{{ user.last_login }}</td>
|
||||||
|
<td>{{ user.name }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<div class="table-responsive" ">
|
||||||
|
<table class="table table-striped" ">
|
||||||
|
|
||||||
|
{% for user in droit.user_set.all %}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<div class="table-responsive" ">
|
||||||
|
<table class="table table-striped" ">
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Pseudo</td>
|
||||||
|
<td>Adhésion</td>
|
||||||
|
<td>Derniere connection</td>
|
||||||
|
<td>Nombre d'actions</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>{{ user.name }}</td>
|
||||||
|
<td>{{ user.is_adherent }}</td>
|
||||||
|
<td>{{ user.last_login }}</td>
|
||||||
|
<td>{{ user.name }}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
|
@ -51,5 +51,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<i class="fa fa-users"></i>
|
<i class="fa fa-users"></i>
|
||||||
Utilisateurs
|
Utilisateurs
|
||||||
</a>
|
</a>
|
||||||
|
<a class="list-group-item list-group-item-info" href="{% url "logs:stats-droits" %}">
|
||||||
|
<i class="fa fa-balance-scale"></i>
|
||||||
|
Groupes de droit
|
||||||
|
</a>
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
36
logs/templates/logs/stats_droits.html
Normal file
36
logs/templates/logs/stats_droits.html
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{% extends "logs/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 %}
|
||||||
|
|
||||||
|
{% block title %}Statistiques des droits{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Statistiques des droits</h2>
|
||||||
|
{% include "logs/aff_stats_droits.html" with stats_list=stats_list %}
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
{% endblock %}
|
|
@ -39,4 +39,5 @@ urlpatterns = [
|
||||||
url(r'^stats_models/$', views.stats_models, name='stats-models'),
|
url(r'^stats_models/$', views.stats_models, name='stats-models'),
|
||||||
url(r'^stats_users/$', views.stats_users, name='stats-users'),
|
url(r'^stats_users/$', views.stats_users, name='stats-users'),
|
||||||
url(r'^stats_actions/$', views.stats_actions, name='stats-actions'),
|
url(r'^stats_actions/$', views.stats_actions, name='stats-actions'),
|
||||||
|
url(r'^stats_droits/$', views.stats_droits, name='stats-droits'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -446,3 +446,10 @@ def stats_actions(request):
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return render(request, 'logs/stats_users.html', {'stats_list': stats})
|
return render(request, 'logs/stats_users.html', {'stats_list': stats})
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_view_app('users')
|
||||||
|
def stats_droits(request):
|
||||||
|
"""Affiche la liste des droits disponibles"""
|
||||||
|
droits=ListRight.objects.all().prefetch_related('user_set')
|
||||||
|
return render(request, 'logs/stats_droits.html', {'stats_list': droits})
|
||||||
|
|
|
@ -133,6 +133,7 @@ MODEL_NAME = {
|
||||||
'ServiceUser' : users.models.ServiceUser,
|
'ServiceUser' : users.models.ServiceUser,
|
||||||
'School' : users.models.School,
|
'School' : users.models.School,
|
||||||
'ListRight' : users.models.ListRight,
|
'ListRight' : users.models.ListRight,
|
||||||
|
'ListShell' : users.models.ListShell,
|
||||||
'Ban' : users.models.Ban,
|
'Ban' : users.models.Ban,
|
||||||
'Whitelist' : users.models.Whitelist,
|
'Whitelist' : users.models.Whitelist,
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ HISTORY_BIND = {
|
||||||
'school' : users.models.School,
|
'school' : users.models.School,
|
||||||
'listright' : users.models.ListRight,
|
'listright' : users.models.ListRight,
|
||||||
'serviceuser' : users.models.ServiceUser,
|
'serviceuser' : users.models.ServiceUser,
|
||||||
|
'shell' : users.models.ListShell,
|
||||||
},
|
},
|
||||||
'preferences' : {
|
'preferences' : {
|
||||||
'service' : preferences.models.Service,
|
'service' : preferences.models.Service,
|
||||||
|
|
|
@ -41,8 +41,17 @@ from django.utils import timezone
|
||||||
from django.contrib.auth.models import Group, Permission
|
from django.contrib.auth.models import Group, Permission
|
||||||
|
|
||||||
from preferences.models import OptionalUser
|
from preferences.models import OptionalUser
|
||||||
from .models import User, ServiceUser, School, ListRight, Whitelist
|
from .models import (
|
||||||
from .models import Ban, Adherent, Club
|
User,
|
||||||
|
ServiceUser,
|
||||||
|
School,
|
||||||
|
ListRight,
|
||||||
|
Whitelist,
|
||||||
|
ListShell,
|
||||||
|
Ban,
|
||||||
|
Adherent,
|
||||||
|
Club
|
||||||
|
)
|
||||||
from re2o.utils import remove_user_room
|
from re2o.utils import remove_user_room
|
||||||
|
|
||||||
from re2o.field_permissions import FieldPermissionFormMixin
|
from re2o.field_permissions import FieldPermissionFormMixin
|
||||||
|
@ -460,6 +469,18 @@ class SchoolForm(ModelForm):
|
||||||
self.fields['name'].label = 'Établissement'
|
self.fields['name'].label = 'Établissement'
|
||||||
|
|
||||||
|
|
||||||
|
class ShellForm(ModelForm):
|
||||||
|
"""Edition, creation d'un école"""
|
||||||
|
class Meta:
|
||||||
|
model = ListShell
|
||||||
|
fields = ['shell']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
|
super(ShellForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
|
self.fields['shell'].label = 'Nom du shell'
|
||||||
|
|
||||||
|
|
||||||
class ListRightForm(ModelForm):
|
class ListRightForm(ModelForm):
|
||||||
"""Edition, d'un groupe , équivalent à un droit
|
"""Edition, d'un groupe , équivalent à un droit
|
||||||
Ne peremet pas d'editer le gid, car il sert de primary key"""
|
Ne peremet pas d'editer le gid, car il sert de primary key"""
|
||||||
|
|
19
users/migrations/0070_auto_20180324_1906.py
Normal file
19
users/migrations/0070_auto_20180324_1906.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2018-03-24 18:06
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('users', '0069_club_mailing'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='listshell',
|
||||||
|
options={'permissions': (('view_listshell', "Peut voir un objet shell quelqu'il soit"),)},
|
||||||
|
),
|
||||||
|
]
|
|
@ -1248,10 +1248,67 @@ class ListShell(models.Model):
|
||||||
|
|
||||||
shell = models.CharField(max_length=255, unique=True)
|
shell = models.CharField(max_length=255, unique=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
permissions = (
|
||||||
|
("view_listshell", "Peut voir un objet shell quelqu'il soit"),
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_instance(shellid, *args, **kwargs):
|
||||||
|
return ListShell.objects.get(pk=shellid)
|
||||||
|
|
||||||
def get_pretty_name(self):
|
def get_pretty_name(self):
|
||||||
"""Return the canonical name of the shell"""
|
"""Return the canonical name of the shell"""
|
||||||
return self.shell.split("/")[-1]
|
return self.shell.split("/")[-1]
|
||||||
|
|
||||||
|
def can_create(user_request, *args, **kwargs):
|
||||||
|
"""Check if an user can create a ListShell object.
|
||||||
|
|
||||||
|
:param user_request: The user who wants to create a user object.
|
||||||
|
:return: a message and a boolean which is True if the user can create.
|
||||||
|
"""
|
||||||
|
return user_request.has_perm('users.add_listshell'), u"Vous n'avez pas le\
|
||||||
|
droit de créer des shells"
|
||||||
|
|
||||||
|
def can_edit(self, user_request, *args, **kwargs):
|
||||||
|
"""Check if an user can edit a ListShell object.
|
||||||
|
|
||||||
|
:param self: The Shell which is to be edited.
|
||||||
|
:param user_request: The user who requests to edit self.
|
||||||
|
:return: a message and a boolean which is True if edition is granted.
|
||||||
|
"""
|
||||||
|
return user_request.has_perm('users.change_listshell'), u"Vous n'avez pas le\
|
||||||
|
droit d'éditer des shells"
|
||||||
|
|
||||||
|
def can_delete(self, user_request, *args, **kwargs):
|
||||||
|
"""Check if an user can delete a ListShell object.
|
||||||
|
|
||||||
|
:param self: The Shell which is to be deleted.
|
||||||
|
:param user_request: The user who requests deletion.
|
||||||
|
:return: True if deletion is granted, and a message.
|
||||||
|
"""
|
||||||
|
return user_request.has_perm('users.delete_listshell'), u"Vous n'avez pas le\
|
||||||
|
droit de supprimer des shells"
|
||||||
|
|
||||||
|
def can_view_all(user_request, *args, **kwargs):
|
||||||
|
"""Check if an user can access to the list of every ListShell objects
|
||||||
|
|
||||||
|
:param user_request: The user who wants to view the list.
|
||||||
|
:return: True if the user can view the list and an explanation message.
|
||||||
|
"""
|
||||||
|
return user_request.has_perm('users.view_listshell'), u"Vous n'avez pas le\
|
||||||
|
droit de voir les shells"
|
||||||
|
|
||||||
|
def can_view(self, user_request, *args, **kwargs):
|
||||||
|
"""Check if an user can view a ListShell object.
|
||||||
|
|
||||||
|
:param self: The targeted ListShell instance.
|
||||||
|
:param user_request: The user who ask for viewing the target.
|
||||||
|
:return: A boolean telling if the acces is granted and an explanation
|
||||||
|
text
|
||||||
|
"""
|
||||||
|
return user_request.has_perm('users.view_listshell'), u"Vous n'avez pas le\
|
||||||
|
droit de voir les shells"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.shell
|
return self.shell
|
||||||
|
|
||||||
|
|
47
users/templates/users/aff_shell.html
Normal file
47
users/templates/users/aff_shell.html
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
{% 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 acl %}
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Shell</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for shell in shell_list %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ shell.shell }}</td>
|
||||||
|
<td class="text-right">
|
||||||
|
{% can_delete shell %}
|
||||||
|
{% include 'buttons/suppr.html' with href='users:del-shell' id=shell.id %}
|
||||||
|
{% acl_end %}
|
||||||
|
{% can_edit shell %}
|
||||||
|
{% include 'buttons/edit.html' with href='users:edit-shell' id=shell.id %}
|
||||||
|
{% acl_end %}
|
||||||
|
{% include 'buttons/history.html' with href='users:history' name='shell' id=shell.id %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
41
users/templates/users/index_shell.html
Normal file
41
users/templates/users/index_shell.html
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{% 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 %}
|
||||||
|
|
||||||
|
{% block title %}Utilisateurs{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Liste des Shells</h2>
|
||||||
|
{% can_create ListShell %}
|
||||||
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-shell' %}"><i class="fa fa-plus"></i> Ajouter un shell</a>
|
||||||
|
{% acl_end %}
|
||||||
|
{% include "users/aff_shell.html" with shell_list=shell_list %}
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -69,6 +69,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
Établissements
|
Établissements
|
||||||
</a>
|
</a>
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
|
{% can_view_all ListShell %}
|
||||||
|
<a class="list-group-item list-group-item-info" href="{% url "users:index-shell" %}">
|
||||||
|
<i class="fa fa-list-ul"></i>
|
||||||
|
Liste des shells
|
||||||
|
</a>
|
||||||
|
{% acl_end %}
|
||||||
{% can_view_all ListRight %}
|
{% can_view_all ListRight %}
|
||||||
<a class="list-group-item list-group-item-info" href="{% url "users:index-listright" %}">
|
<a class="list-group-item list-group-item-info" href="{% url "users:index-listright" %}">
|
||||||
<i class="fa fa-list-ul"></i>
|
<i class="fa fa-list-ul"></i>
|
||||||
|
|
|
@ -80,10 +80,22 @@ urlpatterns = [
|
||||||
name='edit-listright'
|
name='edit-listright'
|
||||||
),
|
),
|
||||||
url(r'^del_listright/$', views.del_listright, name='del-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<shellid>[0-9]+)$',
|
||||||
|
views.edit_shell,
|
||||||
|
name='edit-shell'
|
||||||
|
),
|
||||||
|
url(
|
||||||
|
r'^del_shell/(?P<shellid>[0-9]+)$',
|
||||||
|
views.del_shell,
|
||||||
|
name='del-shell'
|
||||||
|
),
|
||||||
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_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_listright/$', views.index_listright, name='index-listright'),
|
||||||
url(
|
url(
|
||||||
r'^index_serviceusers/$',
|
r'^index_serviceusers/$',
|
||||||
|
|
|
@ -45,8 +45,10 @@ from django.db import IntegrityError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from django.http import HttpResponseRedirect
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
|
|
||||||
from rest_framework.renderers import JSONRenderer
|
from rest_framework.renderers import JSONRenderer
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +65,7 @@ from users.models import (
|
||||||
ServiceUser,
|
ServiceUser,
|
||||||
Adherent,
|
Adherent,
|
||||||
Club,
|
Club,
|
||||||
|
ListShell,
|
||||||
)
|
)
|
||||||
from users.forms import (
|
from users.forms import (
|
||||||
BanForm,
|
BanForm,
|
||||||
|
@ -72,6 +75,7 @@ from users.forms import (
|
||||||
NewListRightForm,
|
NewListRightForm,
|
||||||
StateForm,
|
StateForm,
|
||||||
SchoolForm,
|
SchoolForm,
|
||||||
|
ShellForm,
|
||||||
EditServiceUserForm,
|
EditServiceUserForm,
|
||||||
ServiceUserForm,
|
ServiceUserForm,
|
||||||
ListRightForm,
|
ListRightForm,
|
||||||
|
@ -273,8 +277,10 @@ def del_group(request, user, userid, listrightid):
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
user.groups.remove(ListRight.objects.get(id=listrightid))
|
user.groups.remove(ListRight.objects.get(id=listrightid))
|
||||||
user.save()
|
user.save()
|
||||||
|
reversion.set_user(request.user)
|
||||||
|
reversion.set_comment("Suppression de droit")
|
||||||
messages.success(request, "Droit supprimé à %s" % user)
|
messages.success(request, "Droit supprimé à %s" % user)
|
||||||
return redirect(reverse('users:index-listright'))
|
return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -492,6 +498,57 @@ def del_school(request, instances):
|
||||||
return form({'userform': school, 'action_name': 'Supprimer'}, 'users/user.html', request)
|
return form({'userform': school, 'action_name': 'Supprimer'}, 'users/user.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_create(ListShell)
|
||||||
|
def add_shell(request):
|
||||||
|
""" Ajouter un établissement d'enseignement à la base de donnée,
|
||||||
|
need cableur"""
|
||||||
|
shell = ShellForm(request.POST or None)
|
||||||
|
if shell.is_valid():
|
||||||
|
with transaction.atomic(), reversion.create_revision():
|
||||||
|
shell.save()
|
||||||
|
reversion.set_user(request.user)
|
||||||
|
reversion.set_comment("Création")
|
||||||
|
messages.success(request, "Le shell a été ajouté")
|
||||||
|
return redirect(reverse('users:index-shell'))
|
||||||
|
return form({'userform': shell, 'action_name':'Ajouter'}, 'users/user.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_edit(ListShell)
|
||||||
|
def edit_shell(request, shell_instance, shellid):
|
||||||
|
""" Editer un établissement d'enseignement à partir du shellid dans
|
||||||
|
la base de donnée, need cableur"""
|
||||||
|
shell = ShellForm(request.POST or None, instance=shell_instance)
|
||||||
|
if shell.is_valid():
|
||||||
|
with transaction.atomic(), reversion.create_revision():
|
||||||
|
shell.save()
|
||||||
|
reversion.set_user(request.user)
|
||||||
|
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(
|
||||||
|
field for field in shell.changed_data
|
||||||
|
))
|
||||||
|
messages.success(request, "Le shell a été modifié")
|
||||||
|
return redirect(reverse('users:index-shell'))
|
||||||
|
return form({'userform': shell, 'action_name':'Editer'}, 'users/user.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_delete(ListShell)
|
||||||
|
def del_shell(request, shell, shellid):
|
||||||
|
"""Destruction d'un shell"""
|
||||||
|
if request.method == "POST":
|
||||||
|
with transaction.atomic(), reversion.create_revision():
|
||||||
|
shell.delete()
|
||||||
|
reversion.set_user(request.user)
|
||||||
|
messages.success(request, "Le shell a été détruit")
|
||||||
|
return redirect(reverse('users:index-shell'))
|
||||||
|
return form(
|
||||||
|
{'objet': shell, 'objet_name': 'shell'},
|
||||||
|
'users/delete.html',
|
||||||
|
request
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(ListRight)
|
@can_create(ListRight)
|
||||||
def add_listright(request):
|
def add_listright(request):
|
||||||
|
@ -690,7 +747,7 @@ def index_white(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_view_all(School)
|
@can_view_all(School)
|
||||||
def index_school(request):
|
def index_school(request):
|
||||||
""" Affiche l'ensemble des établissement, need droit cableur """
|
""" Affiche l'ensemble des établissement"""
|
||||||
school_list = School.objects.order_by('name')
|
school_list = School.objects.order_by('name')
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
|
@ -699,10 +756,22 @@ 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
|
@login_required
|
||||||
@can_view_all(ListRight)
|
@can_view_all(ListRight)
|
||||||
def index_listright(request):
|
def index_listright(request):
|
||||||
""" Affiche l'ensemble des droits , need droit cableur """
|
""" Affiche l'ensemble des droits"""
|
||||||
listright_list = ListRight.objects.order_by('unix_name')\
|
listright_list = ListRight.objects.order_by('unix_name')\
|
||||||
.prefetch_related('permissions').prefetch_related('user_set')
|
.prefetch_related('permissions').prefetch_related('user_set')
|
||||||
return render(
|
return render(
|
||||||
|
|
Loading…
Reference in a new issue