Compare commits

...

2 commits

Author SHA1 Message Date
j
6faa6f502b weeks 2025-02-23 11:47:20 -05:00
j
9d7659ef40 fix send_week 2025-02-23 11:32:02 -05:00
4 changed files with 7 additions and 4 deletions

View file

@ -2,6 +2,7 @@ import json
import xml.etree.ElementTree as ET
import ox
import isoweek
from django.utils import timezone
from django.utils.timezone import datetime, timedelta
@ -49,7 +50,7 @@ def get_byline(week):
def get_weeks(archive):
weeks = sorted(set(archive.values_list('year', 'week')))
weeks = [datetime.strptime('%s-W%s-1' % w, "%Y-W%U-%w").strftime('%Y-%m-%d') for w in weeks]
weeks = [isoweek.Week(*w).monday().strftime('%Y-%m-%d') for w in weeks]
weeks = [{
'date': week,
'year': week.split('-')[0],
@ -89,7 +90,7 @@ def archive(request, year=None, month=None, day=None, week=None):
archive = models.Item.all_public()
if year and month and day:
date = datetime.strptime('%s-%s-%s' % (year, month, day), '%Y-%m-%d')
week = int(date.strftime('%U'))
week = date.isocalendar()[1]
year = int(year)
archive_week = archive.filter(year=year, week=week).order_by('published')
years = {}

View file

@ -23,7 +23,8 @@ def get_auth(headers):
def send_week(monday):
from . import views
monday = views.get_monday(monday)
date = datetime.strptime(date, '%Y-%m-%d')
monday = views.get_monday(date)
year, month, day = monday.split('-')
body = views.week(year, month, day)
name = 'weekly-digest-%s' % 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('%U'))
week = date.isocalendar()[1]
year = int(year)
archive_week = archive.filter(year=year, week=week).order_by('published')
context['weeks'] = get_weeks(archive)

View file

@ -15,3 +15,4 @@ redis
django-brake
python-telegram-bot
ox
isoweek