diff --git a/management/commands/check_consistency.py b/management/commands/check_consistency.py index 83fec968f08dafe6dc4bb4616b2401a0aefd6e8e..52497231ae70ea3e4f8cfe35d06f20c5106c39cc 100644 --- a/management/commands/check_consistency.py +++ b/management/commands/check_consistency.py @@ -23,10 +23,11 @@ class Command(BaseCommand): if options["sum_all"]: s = Note.objects.aggregate(Sum("balance"))["balance__sum"] if s: - err_log += self.style.NOTICE("LA SOMME DES NOTES NE VAUT PAS ZÉRO : " + pretty_money(s)) + "\n" + self.stderr.write(self.style.NOTICE("LA SOMME DES NOTES NE VAUT PAS ZÉRO : " + pretty_money(s))) error = True else: - self.stdout.write(self.style.SUCCESS("La somme des notes vaut bien zéro.")) + if options["verbosity"] > 0: + self.stdout.write(self.style.SUCCESS("La somme des notes vaut bien zéro.")) notes = Note.objects.none() if options["check_all"]: @@ -42,19 +43,13 @@ class Command(BaseCommand): .annotate(total=F("quantity") * F("amount")).aggregate(Sum("total"))["total__sum"] or 0 calculated_balance = incoming - outcoming if calculated_balance != balance: - err_log += self.style.NOTICE("LA SOMME DES TRANSACTIONS DE LA NOTE {} NE CORRESPOND PAS " - "AVEC LE MONTANT RÉEL".format(str(note))) + "\n" - err_log += self.style.NOTICE("Attendu : {}, calculé : {}" - .format(pretty_money(balance), pretty_money(calculated_balance))) + "\n" + self.stderr.write(self.style.NOTICE(f"LA SOMME DES TRANSACTIONS DE LA NOTE {note} NE CORRESPOND PAS " + "AVEC LE MONTANT RÉEL")) + self.stderr.write(self.style.NOTICE(f"Attendu : {pretty_money(balance)}, " + f"calculé : {pretty_money(calculated_balance)}")) if options["fix"]: note.balance = calculated_balance note.save() error = True - if error: - self.stderr.write(err_log) - if options["mail"]: - send_mail("[Note Kfet] La base de données n'est pas consistante", err_log, - "NoteKfet2020 <notekfet2020@crans.org>", ["respo-info.bde@lists.crans.org"]) - exit(1 if error else 0) diff --git a/management/commands/compilejsmessages.py b/management/commands/compilejsmessages.py index f36328e1c04c465491155164f32fc70aca86e0e6..c66686ad88c3edd0f01a504d2bbe6ae0087f6d4b 100644 --- a/management/commands/compilejsmessages.py +++ b/management/commands/compilejsmessages.py @@ -19,7 +19,8 @@ class Command(BaseCommand): for code, _ in settings.LANGUAGES: if code == settings.LANGUAGE_CODE: continue - self.stdout.write(f"Generate {code} javascript localization file") + if kwargs["verbosity"] > 0: + self.stdout.write(f"Generate {code} javascript localization file") with translation.override(code): resp = JavaScriptCatalog().get(None, packages="member+note") if not os.path.isdir(kwargs["out"] + "/js/jsi18n"): diff --git a/management/commands/extract_ml_registrations.py b/management/commands/extract_ml_registrations.py index 1e8f47255af913cf10db4853ae3f2bee030a7b0d..afcd7cc4bf66bc7dda929e8beea053449a2dab1e 100644 --- a/management/commands/extract_ml_registrations.py +++ b/management/commands/extract_ml_registrations.py @@ -25,6 +25,10 @@ class Command(BaseCommand): def handle(self, *args, **options): # TODO: Improve the mailing list extraction system, and link it automatically with Mailman. + if options['verbosity'] == 0: + # This is useless, but this what the user asked. + return + if options["type"] == "members": for membership in Membership.objects.filter( club__name="BDE", diff --git a/management/commands/make_su.py b/management/commands/make_su.py index cab3c6f38b70c63a32278c0f8d1153a2812ef9c3..692d43a2cd4a7587fd6935ce1a665926de25db14 100644 --- a/management/commands/make_su.py +++ b/management/commands/make_su.py @@ -16,7 +16,11 @@ class Command(BaseCommand): user = User.objects.get(username=uname) user.is_active = True if kwargs['STAFF']: + if kwargs['verbosity'] > 0: + self.stdout.write(f"Add {user} to staff users...") user.is_staff = True if kwargs['SUPER']: + if kwargs['verbosity'] > 0: + self.stdout.write(f"Add {user} to superusers...") user.is_superuser = True user.save() diff --git a/management/commands/refresh_highlighted_buttons.py b/management/commands/refresh_highlighted_buttons.py index bcf53c40d63d31a95fa1d0b78a1649f88338374e..fa73cb6c101c82bc966ffd66eb7e4620a261c4a8 100644 --- a/management/commands/refresh_highlighted_buttons.py +++ b/management/commands/refresh_highlighted_buttons.py @@ -23,7 +23,8 @@ class Command(BaseCommand): for d in queryset.all(): button_id = d["template"] button = TransactionTemplate.objects.get(pk=button_id) - self.stdout.write(self.style.WARNING("Highlight button {name} ({count:d} transactions)..." - .format(name=button.name, count=d["transaction_count"]))) + if kwargs['verbosity'] > 0: + self.stdout.write(self.style.WARNING("Highlight button {name} ({count:d} transactions)..." + .format(name=button.name, count=d["transaction_count"]))) button.highlighted = True button.save()