week number

This commit is contained in:
j 2025-02-23 11:19:23 -05:00
commit 21311303e1
3 changed files with 5 additions and 7 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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)