From 2d91dfcacb94ef9aef93f6ccc41815a751b3215e Mon Sep 17 00:00:00 2001 From: j Date: Sun, 10 Dec 2023 10:08:31 +0000 Subject: [PATCH] don't fail if week does not exist yet --- app/listmonk/tasks.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/listmonk/tasks.py b/app/listmonk/tasks.py index c4b8a50..cf4e307 100644 --- a/app/listmonk/tasks.py +++ b/app/listmonk/tasks.py @@ -24,10 +24,11 @@ def send_week(): week, archive = models.Item.public(now) week_obj = models.Week.objects.filter(monday=monday).first() notified_key = "week-%s-notified" % monday - if not week_obj and not cache.get(notified_key): - message = "no title for week, can not send out email please add: %s/admin/item/week/add/?monday=%s" % (settings.URL, monday) - r = rpc.send(message, group=settings.SIGNAL_MODERATORS_GROUP) - cache.set(notified_key, True, 24*60*60) + if not week_obj: + if not cache.get(notified_key): + message = "no title for week, can not send out email please add: %s/admin/item/week/add/?monday=%s" % (settings.URL, monday) + r = rpc.send(message, group=settings.SIGNAL_MODERATORS_GROUP) + cache.set(notified_key, True, 24*60*60) elif week.filter(announced=None).exists(): logger.error("waiting for last item of the week to be public") elif not week_obj.published: