Fix adherents name
This commit is contained in:
parent
2ce5e122a4
commit
79ad58997a
|
@ -78,7 +78,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
<li><strong>{% trans 'maximum borrowed' %}</strong> : {{ user.maxemprunt }}</li>
|
||||
<li>
|
||||
<strong>{% trans 'membership for current year' %}</strong> :
|
||||
{% if user.is_adherent %}
|
||||
{% if user.is_member %}
|
||||
<span style="color:green">{% trans 'yes' %}</span>
|
||||
{% else %}
|
||||
<span style="color:red">{% trans 'no' %}</span>
|
||||
|
|
|
@ -28,9 +28,9 @@ class AdhesionAdmin(VersionAdmin):
|
|||
autocomplete_fields = ('members',)
|
||||
|
||||
|
||||
class IsAdherentFilter(admin.SimpleListFilter):
|
||||
title = _('adherent status')
|
||||
parameter_name = 'is_adherent'
|
||||
class IsMemberFilter(admin.SimpleListFilter):
|
||||
title = _('membership status')
|
||||
parameter_name = 'is_member'
|
||||
|
||||
def lookups(self, request, model_admin):
|
||||
return (
|
||||
|
@ -43,7 +43,7 @@ class IsAdherentFilter(admin.SimpleListFilter):
|
|||
# Get current membership year and list all members
|
||||
last_adh_year = Adhesion.objects.all().order_by('starting_in') \
|
||||
.reverse().first()
|
||||
return last_adh_year.adherent
|
||||
return last_adh_year.members
|
||||
return queryset
|
||||
|
||||
|
||||
|
@ -59,8 +59,8 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
|
|||
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
|
||||
)
|
||||
list_display = ('username', 'email', 'first_name', 'last_name',
|
||||
'maxemprunt', 'is_adherent', 'is_staff')
|
||||
list_filter = (IsAdherentFilter, 'is_staff', 'is_superuser', 'is_active',
|
||||
'maxemprunt', 'is_member', 'is_staff')
|
||||
list_filter = (IsMemberFilter, 'is_staff', 'is_superuser', 'is_active',
|
||||
'groups')
|
||||
|
||||
# Customize required initial fields
|
||||
|
@ -91,13 +91,13 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
|
|||
else:
|
||||
messages.error(request, _("The email is invalid."))
|
||||
|
||||
def is_adherent(self, obj):
|
||||
def is_member(self, obj):
|
||||
"""
|
||||
Get current membership year and check if user is there
|
||||
"""
|
||||
last_adh_year = Adhesion.objects.all().order_by('starting_in') \
|
||||
.reverse().first()
|
||||
is_member = last_adh_year and obj in last_adh_year.adherent.all()
|
||||
is_member = last_adh_year and obj in last_adh_year.members.all()
|
||||
if is_member:
|
||||
return format_html(
|
||||
'<img src="/static/admin/img/icon-yes.svg" alt="True">'
|
||||
|
@ -111,8 +111,8 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
|
|||
_('Adhere')
|
||||
)
|
||||
|
||||
is_adherent.short_description = _('is adherent')
|
||||
is_adherent.allow_tags = True
|
||||
is_member.short_description = _('is member')
|
||||
is_member.allow_tags = True
|
||||
|
||||
|
||||
admin_site.register(User, UserAdmin)
|
||||
|
|
|
@ -3,7 +3,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-08-10 16:12+0200\n"
|
||||
"POT-Creation-Date: 2019-08-10 16:20+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -14,7 +14,7 @@ msgstr ""
|
|||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: admin.py:32
|
||||
msgid "adherent status"
|
||||
msgid "membership status"
|
||||
msgstr "statut adhérent"
|
||||
|
||||
#: admin.py:37
|
||||
|
@ -46,7 +46,7 @@ msgid "Adhere"
|
|||
msgstr "Adhérer"
|
||||
|
||||
#: admin.py:114
|
||||
msgid "is adherent"
|
||||
msgid "is member"
|
||||
msgstr "statut adhérent"
|
||||
|
||||
#: apps.py:15
|
||||
|
|
|
@ -44,10 +44,10 @@ class User(AbstractUser):
|
|||
REQUIRED_FIELDS = ['first_name', 'last_name', 'email']
|
||||
|
||||
@property
|
||||
def is_adherent(self):
|
||||
last_adh_year = Adhesion.objects.all().order_by(
|
||||
def is_member(self):
|
||||
last_year = Adhesion.objects.all().order_by(
|
||||
'starting_in').reverse().first()
|
||||
return last_adh_year and self in last_adh_year.adherent.all()
|
||||
return last_year and self in last_year.members.all()
|
||||
|
||||
|
||||
class Clef(models.Model):
|
||||
|
|
|
@ -55,7 +55,7 @@ def adherer(request, userid):
|
|||
return redirect("admin:users_user_changelist")
|
||||
with transaction.atomic(), reversion.create_revision():
|
||||
reversion.set_user(request.user)
|
||||
adh_year.adherent.add(users)
|
||||
adh_year.members.add(users)
|
||||
adh_year.save()
|
||||
reversion.set_comment("Adhesion de %s" % users)
|
||||
messages.success(request, "Adhesion effectuee")
|
||||
|
|
Loading…
Reference in New Issue