From 2495128755f4d1fd803bfc3b641db8074fa65310 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 9 Aug 2020 15:53:47 +0200 Subject: [PATCH] :bug: Last report date is a datetime, not a date --- management/commands/import_account.py | 2 +- management/commands/send_reports.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/management/commands/import_account.py b/management/commands/import_account.py index 05e9aa9..0e35247 100644 --- a/management/commands/import_account.py +++ b/management/commands/import_account.py @@ -132,7 +132,7 @@ class Command(ImportCommand): "email_confirmed": True, "promotion": MAP_IDBDE_PROMOTION[row["idbde"]]["promo"], "report_frequency": row["report_period"], - "last_report": make_aware(row["previous_report_date"]).date(), + "last_report": make_aware(row["previous_report_date"]), } note_dict["created_at"] = make_aware(MAP_IDBDE_PROMOTION[row["idbde"]]["created_at"]) note_dict["polymorphic_ctype"] = note_user_type diff --git a/management/commands/send_reports.py b/management/commands/send_reports.py index 05d7133..fac74f6 100644 --- a/management/commands/send_reports.py +++ b/management/commands/send_reports.py @@ -23,10 +23,10 @@ class Command(BaseCommand): for note in notes: now = timezone.now() last_report = note.user.profile.last_report - delta = now.date() - last_report + delta = now.date() - last_report.date() if delta.days < note.user.profile.report_frequency: continue - note.user.profile.last_report = now.date() + note.user.profile.last_report = now note.user.profile.save() last_transactions = Transaction.objects.filter( Q(source=note) | Q(destination=note),