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