Compare commits
2 commits
b20760f688
...
6faa6f502b
| Author | SHA1 | Date | |
|---|---|---|---|
| 6faa6f502b | |||
| 9d7659ef40 |
4 changed files with 7 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ import json
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
|
import isoweek
|
||||||
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.timezone import datetime, timedelta
|
from django.utils.timezone import datetime, timedelta
|
||||||
|
|
@ -49,7 +50,7 @@ def get_byline(week):
|
||||||
|
|
||||||
def get_weeks(archive):
|
def get_weeks(archive):
|
||||||
weeks = sorted(set(archive.values_list('year', 'week')))
|
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 = [{
|
weeks = [{
|
||||||
'date': week,
|
'date': week,
|
||||||
'year': week.split('-')[0],
|
'year': week.split('-')[0],
|
||||||
|
|
@ -89,7 +90,7 @@ def archive(request, year=None, month=None, day=None, week=None):
|
||||||
archive = models.Item.all_public()
|
archive = models.Item.all_public()
|
||||||
if year and month and day:
|
if year and month and day:
|
||||||
date = datetime.strptime('%s-%s-%s' % (year, month, day), '%Y-%m-%d')
|
date = datetime.strptime('%s-%s-%s' % (year, month, day), '%Y-%m-%d')
|
||||||
week = int(date.strftime('%U'))
|
week = date.isocalendar()[1]
|
||||||
year = int(year)
|
year = int(year)
|
||||||
archive_week = archive.filter(year=year, week=week).order_by('published')
|
archive_week = archive.filter(year=year, week=week).order_by('published')
|
||||||
years = {}
|
years = {}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@ def get_auth(headers):
|
||||||
|
|
||||||
def send_week(monday):
|
def send_week(monday):
|
||||||
from . import views
|
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('-')
|
year, month, day = monday.split('-')
|
||||||
body = views.week(year, month, day)
|
body = views.week(year, month, day)
|
||||||
name = 'weekly-digest-%s' % monday
|
name = 'weekly-digest-%s' % monday
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ def week(year, month, day):
|
||||||
week=ExtractWeek('published')
|
week=ExtractWeek('published')
|
||||||
)
|
)
|
||||||
date = datetime.strptime('%s-%s-%s' % (year, month, day), '%Y-%m-%d')
|
date = datetime.strptime('%s-%s-%s' % (year, month, day), '%Y-%m-%d')
|
||||||
week = int(date.strftime('%U'))
|
week = date.isocalendar()[1]
|
||||||
year = int(year)
|
year = int(year)
|
||||||
archive_week = archive.filter(year=year, week=week).order_by('published')
|
archive_week = archive.filter(year=year, week=week).order_by('published')
|
||||||
context['weeks'] = get_weeks(archive)
|
context['weeks'] = get_weeks(archive)
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,4 @@ redis
|
||||||
django-brake
|
django-brake
|
||||||
python-telegram-bot
|
python-telegram-bot
|
||||||
ox
|
ox
|
||||||
|
isoweek
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue