Commit 137f63ff authored by Fabs's avatar Fabs
Browse files

Improve admin messages after sending call for membership emails

parent 61738e48
......@@ -60,7 +60,7 @@ class MemberAdmin(UserAdmin):
('username', 'password'))}),
('Permissions', {'fields': (
('is_active', 'is_staff', 'is_superuser'))}),
(None, {'fields':('date_last_call_for_membership_fees_email',)})
(None, {'fields': ('date_last_call_for_membership_fees_email',)})
)
add_fieldsets = (
......@@ -147,7 +147,8 @@ class MemberAdmin(UserAdmin):
depuis une sélection de membre dans la vue liste de l'admin
"""
for member in queryset.all():
self.send_welcome_email(request, member.id, return_httpredirect=False)
self.send_welcome_email(
request, member.id, return_httpredirect=False)
messages.success(request,
'Le courriel de bienvenue a été envoyé à %d membre(s).' % queryset.count())
bulk_send_welcome_email.short_description = "Envoyer le courriel de bienvenue"
......@@ -159,11 +160,32 @@ class MemberAdmin(UserAdmin):
request, 'Vous n\'avez pas l\'autorisation d\'envoyer des '
'courriels de relance.')
return
cpt_success = 0
for member in queryset.all():
member.send_call_for_membership_fees_email()
messages.success(request,
'Le courriel de relance de cotisation a été envoyé à %d membre(s).' % queryset.count())
if member.send_call_for_membership_fees_email():
cpt_success += 1
else:
messages.warning(request,
"Le courriel de relance de cotisation n\'a pas "
"été envoyé à {member} ({email}) car il a déjà "
"reçu une relance le {last_call_date}"\
.format(member=member,
email=member.email,
last_call_date=member.date_last_call_for_membership_fees_email))
if queryset.count() == 1 and cpt_success == 1:
member = queryset.first()
messages.success(request,
"Le courriel de relance de cotisation a été "
"envoyé à {member} ({email})"\
.format(member=member, email=member.email))
elif cpt_success>1:
messages.success(request,
"Le courriel de relance de cotisation a été "
"envoyé à {cpt} membres"\
.format(cpt=cpt_success))
bulk_send_call_for_membership_fee_email.short_description = 'Envoyer le courriel de relance de cotisation'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment