diff --git a/app/listmonk/tasks.py b/app/listmonk/tasks.py index f6de4fe..342ac47 100644 --- a/app/listmonk/tasks.py +++ b/app/listmonk/tasks.py @@ -32,10 +32,9 @@ def send_week(): elif week.filter(announced=None).exists(): logger.error("waiting for last item of the week to be public") elif not week_obj.published: - monday = views.get_monday(now) week_obj.published = now week_obj.save() - if not utils.send_week(now.strftime('%Y-%m-%d')): + if not utils.send_week(monday): message = "weekly newsletter ready, confirm at https://list.phantas.ma/admin/campaigns" r = rpc.send(message, group=settings.SIGNAL_MODERATORS_GROUP) diff --git a/app/listmonk/utils.py b/app/listmonk/utils.py index 0ea078f..001fa5a 100644 --- a/app/listmonk/utils.py +++ b/app/listmonk/utils.py @@ -21,11 +21,10 @@ def get_auth(headers): return auth -def send_week(date): +def send_week(monday): from . import views - year, month, day = date.split('-') - date = datetime.strptime(date, '%Y-%m-%d') - monday = views.get_monday(date) + monday = views.get_monday(monday) + year, month, day = monday.split('-') body = views.week(year, month, day) name = 'weekly-digest-%s' % monday subject = 'Phantas.ma weekly update %s' % views.format_week(monday) diff --git a/app/listmonk/views.py b/app/listmonk/views.py index 767e84a..2aa4c80 100644 --- a/app/listmonk/views.py +++ b/app/listmonk/views.py @@ -34,7 +34,7 @@ def week(year, month, day): week=ExtractWeek('published') ) date = datetime.strptime('%s-%s-%s' % (year, month, day), '%Y-%m-%d') - week = int(date.strftime('%W')) + week = int(date.strftime('%U')) year = int(year) archive_week = archive.filter(year=year, week=week).order_by('published') context['weeks'] = get_weeks(archive)