Commit 41e51c75 authored by Baptiste Jonglez's avatar Baptiste Jonglez
Browse files

Don't output anything if a command does nothing (useful for cron, to avoid sending emails)

parent 7c19c3da
......@@ -20,11 +20,13 @@ class Command(BaseCommand):
raise CommandError(
'Please enter a valid date : YYYY-mm-dd (ex: 2011-07-04)')
self.stdout.write(
'Create invoices for all members for the date : %s' % date)
if options['verbosity'] >= 2:
self.stdout.write(
'Create invoices for all members for the date : %s' % date)
with respect_language(settings.LANGUAGE_CODE):
invoices = create_all_members_invoices_for_a_period(date)
self.stdout.write(
u'%d invoices were created' % len(invoices))
if invoices > 0 or options['verbosity'] >= 2:
self.stdout.write(
u'%d invoices were created' % len(invoices))
......@@ -35,15 +35,17 @@ class Command(BaseCommand):
date,
date + relativedelta(months=+1)]
self.stdout.write("Selecting members whose membership fee end at the "
"following dates : {dates}".format(
dates=[str(d) for d in end_dates]))
if options['verbosity'] >= 2:
self.stdout.write("Selecting members whose membership fee end at "
"the following dates : {dates}".format(
dates=[str(d) for d in end_dates]))
members = Member.objects.filter(status='member')\
.annotate(end=Max('membership_fees__end_date'))\
.filter(end__in=end_dates)
self.stdout.write(
"Got {number} members.".format(number=members.count()))
if options['verbosity'] >= 2:
self.stdout.write(
"Got {number} members.".format(number=members.count()))
cpt = 0
with respect_language(settings.LANGUAGE_CODE):
......@@ -54,5 +56,6 @@ class Command(BaseCommand):
member=member, email=member.email))
cpt = cpt + 1
self.stdout.write("{number} call for membership fees emails were "
"sent".format(number=cpt))
if cpt > 0 or options['verbosity'] >= 2:
self.stdout.write("{number} call for membership fees emails were "
"sent".format(number=cpt))
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