mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2025-07-06 06:03:54 +02:00
Continue to remove old perm system
This commit is contained in:
@ -7,17 +7,13 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from reversion.admin import VersionAdmin
|
||||
|
||||
from .models import Adhesion, Clef, ListRight, Request, Right, User
|
||||
from .models import Adhesion, Clef, Request, User
|
||||
|
||||
|
||||
class RequestAdmin(admin.ModelAdmin):
|
||||
list_display = ('user', 'type', 'created_at', 'expires_at')
|
||||
|
||||
|
||||
class RightAdmin(VersionAdmin):
|
||||
list_display = ('user', 'right')
|
||||
|
||||
|
||||
class ClefAdmin(VersionAdmin):
|
||||
list_display = ('nom', 'proprio', 'commentaire')
|
||||
# TODO order by nom
|
||||
@ -27,10 +23,6 @@ class AdhesionAdmin(VersionAdmin):
|
||||
list_display = ('annee_debut', 'annee_fin')
|
||||
|
||||
|
||||
class ListRightAdmin(VersionAdmin):
|
||||
list_display = ('listright',)
|
||||
|
||||
|
||||
class IsAdherentFilter(admin.SimpleListFilter):
|
||||
title = _('adherent status')
|
||||
parameter_name = 'is_adherent'
|
||||
@ -44,7 +36,7 @@ class IsAdherentFilter(admin.SimpleListFilter):
|
||||
value = self.value()
|
||||
if value == 'Yes':
|
||||
# Get current membership year and list all members
|
||||
last_adh_year = Adhesion.objects.all().order_by('annee_debut')\
|
||||
last_adh_year = Adhesion.objects.all().order_by('annee_debut') \
|
||||
.reverse().first()
|
||||
return last_adh_year.adherent
|
||||
return queryset
|
||||
@ -70,17 +62,20 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
|
||||
"""
|
||||
Get current membership year and check if user is there
|
||||
"""
|
||||
last_adh_year = Adhesion.objects.all().order_by('annee_debut')\
|
||||
last_adh_year = Adhesion.objects.all().order_by('annee_debut') \
|
||||
.reverse().first()
|
||||
return last_adh_year and obj in last_adh_year.adherent.all()
|
||||
|
||||
is_adherent.boolean = True
|
||||
is_adherent.short_description = _('is adherent')
|
||||
|
||||
# TODO {% if not user.is_adherent and perms.users.add_user %}
|
||||
# {% url 'users:adherer' user.id %}
|
||||
# TODO {% if perms.media.add_emprunt %}
|
||||
# {% url 'media:add-emprunt' user.id %}">
|
||||
|
||||
|
||||
admin.site.register(User, UserAdmin)
|
||||
admin.site.register(Request, RequestAdmin)
|
||||
admin.site.register(ListRight, ListRightAdmin)
|
||||
admin.site.register(Right, RightAdmin)
|
||||
admin.site.register(Adhesion, AdhesionAdmin)
|
||||
admin.site.register(Clef, ClefAdmin)
|
||||
|
Reference in New Issue
Block a user