From 5b96a94774fa91b157eedf59d5c13f48c5647e3a Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Wed, 11 Oct 2017 21:58:36 +0200 Subject: [PATCH] add BanType in admin site --- users/admin.py | 5 ++++- users/models.py | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/users/admin.py b/users/admin.py index 6a1e0e74..85485311 100644 --- a/users/admin.py +++ b/users/admin.py @@ -28,7 +28,7 @@ from django.contrib.auth.models import Group from django.contrib.auth.admin import UserAdmin as BaseUserAdmin from reversion.admin import VersionAdmin -from .models import User, ServiceUser, School, Right, ListRight, ListShell, Ban, Whitelist, Request, LdapUser, LdapServiceUser, LdapServiceUserGroup, LdapUserGroup +from .models import User, ServiceUser, School, Right, ListRight, ListShell, BanType, Ban, Whitelist, Request, LdapUser, LdapServiceUser, LdapServiceUserGroup, LdapUserGroup from .forms import UserChangeForm, UserCreationForm, ServiceUserChangeForm, ServiceUserCreationForm @@ -82,6 +82,8 @@ class RequestAdmin(admin.ModelAdmin): class BanAdmin(VersionAdmin): list_display = ('user', 'raison', 'date_start', 'date_end') +class BanTypeAdmin(VersionAdmin): + list_display = ('name', 'description') class WhitelistAdmin(VersionAdmin): list_display = ('user', 'raison', 'date_start', 'date_end') @@ -151,6 +153,7 @@ admin.site.register(Right, RightAdmin) admin.site.register(ListRight, ListRightAdmin) admin.site.register(ListShell, ListShellAdmin) admin.site.register(Ban, BanAdmin) +admin.site.register(BanType, BanTypeAdmin) admin.site.register(Whitelist, WhitelistAdmin) admin.site.register(Request, RequestAdmin) # Now register the new UserAdmin... diff --git a/users/models.py b/users/models.py index 9da64a9e..cd59b8e5 100644 --- a/users/models.py +++ b/users/models.py @@ -737,8 +737,7 @@ class BanType(models.Model): class Ban(models.Model): - """ Bannissement. Actuellement a un effet tout ou rien. - Gagnerait à être granulaire""" + """ Bannissement d'un utilisateur donné pour un motif/effet fourni.""" PRETTY_NAME = "Liste des bannissements" user = models.ForeignKey('User', on_delete=models.PROTECT) @@ -748,7 +747,9 @@ class Ban(models.Model): ban_type = models.ForeignKey(BanType) def notif_ban(self): - """ Prend en argument un objet ban, envoie un mail de notification """ + """ Prend en argument un objet ban, envoie un mail de notification. + À terme, il serait envisageable de déporter cette méthode sur le modèle + BanType afin de fournir un message différent suivant le type de Ban.""" general_options, created = GeneralOption.objects.get_or_create() t = loader.get_template('users/email_ban_notif') options, created = AssoOption.objects.get_or_create()