mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 15:33:45 +00:00
add BanType in admin site
This commit is contained in:
parent
4c23daa477
commit
5b96a94774
2 changed files with 8 additions and 4 deletions
|
@ -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...
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue