Browse Source

Fix verbosity being a string and not an int

Baptiste Jonglez 10 years ago
parent
commit
bfdb454bfd

+ 3 - 2
coin/billing/management/commands/charge_subscriptions.py

@@ -12,6 +12,7 @@ class Command(BaseCommand):
     help = 'Create invoices for members subscriptions for date specified (or today if no date passed)'
 
     def handle(self, *args, **options):
+        verbosity = int(options['verbosity'])
         try:
             date = datetime.datetime.strptime(args[0], '%Y-%m-%d').date()
         except IndexError:
@@ -20,13 +21,13 @@ class Command(BaseCommand):
             raise CommandError(
                 'Please enter a valid date : YYYY-mm-dd (ex: 2011-07-04)')
 
-        if options['verbosity'] >= 2:
+        if 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)
 
-        if invoices > 0 or options['verbosity'] >= 2:
+        if invoices > 0 or verbosity >= 2:
             self.stdout.write(
                 u'%d invoices were created' % len(invoices))
 

+ 4 - 3
coin/members/management/commands/call_for_membership_fees.py

@@ -21,6 +21,7 @@ class Command(BaseCommand):
               can be passed as argument."""
 
     def handle(self, *args, **options):
+        verbosity = int(options['verbosity'])
         try:
             date = datetime.datetime.strptime(args[0], '%Y-%m-%d').date()
         except IndexError:
@@ -35,7 +36,7 @@ class Command(BaseCommand):
                      date,
                      date + relativedelta(months=+1)]
 
-        if options['verbosity'] >= 2:
+        if 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]))
@@ -43,7 +44,7 @@ class Command(BaseCommand):
         members = Member.objects.filter(status='member')\
                                 .annotate(end=Max('membership_fees__end_date'))\
                                 .filter(end__in=end_dates)
-        if options['verbosity'] >= 2:
+        if verbosity >= 2:
             self.stdout.write(
                 "Got {number} members.".format(number=members.count()))
 
@@ -56,6 +57,6 @@ class Command(BaseCommand):
                             member=member, email=member.email))
                     cpt = cpt + 1
 
-        if cpt > 0 or options['verbosity'] >= 2:
+        if cpt > 0 or verbosity >= 2:
             self.stdout.write("{number} call for membership fees emails were "
                               "sent".format(number=cpt))