weeks
This commit is contained in:
parent
9d7659ef40
commit
6faa6f502b
3 changed files with 5 additions and 3 deletions
|
|
@ -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 = {}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -15,3 +15,4 @@ redis
|
|||
django-brake
|
||||
python-telegram-bot
|
||||
ox
|
||||
isoweek
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue