timeline output
This commit is contained in:
parent
05413ad9f8
commit
c5dc81d363
101 changed files with 13735 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import json
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.conf import settings
|
||||
|
||||
|
|
@ -12,3 +14,58 @@ def index(request, slug=''):
|
|||
context['postscript'], c = Page.objects.get_or_create(slug='postscript')
|
||||
context['intro'], c = Page.objects.get_or_create(slug='intro')
|
||||
return render(request, 'index.html', context)
|
||||
|
||||
def timeline(request):
|
||||
context = {}
|
||||
context['settings'] = settings
|
||||
context['postscript'], c = Page.objects.get_or_create(slug='postscript')
|
||||
context['intro'], c = Page.objects.get_or_create(slug='intro')
|
||||
|
||||
timeline = {'events': []}
|
||||
for event in Event.objects.all().order_by('position'):
|
||||
if not event.date:
|
||||
continue
|
||||
date = event.date.split(' ')
|
||||
start = date[0].split('-')
|
||||
if len(date) > 1:
|
||||
end = date[1].split('-')
|
||||
else:
|
||||
end = start
|
||||
while len(end) < 3:
|
||||
end.append(1)
|
||||
while len(start) < 3:
|
||||
start.appstart(1)
|
||||
|
||||
timeline['events'].append({
|
||||
"start_date": {
|
||||
"year": start[0],
|
||||
"month": start[1],
|
||||
"day": start[2],
|
||||
"hour": "",
|
||||
"minute": "",
|
||||
"second": "",
|
||||
"millisecond": "",
|
||||
"format": ""
|
||||
},
|
||||
"end_date": {
|
||||
"year": end[0],
|
||||
"month": end[1],
|
||||
"day": end[2],
|
||||
"hour": "",
|
||||
"minute": "",
|
||||
"second": "",
|
||||
"millisecond": "",
|
||||
"format": ""
|
||||
},
|
||||
#"media": {
|
||||
# "caption": event.title,
|
||||
# "credit": "",
|
||||
#},
|
||||
"text": {
|
||||
"headline": event.title,
|
||||
"text": event.body
|
||||
},
|
||||
"unique_id": event.slug
|
||||
})
|
||||
context['timeline_json'] = json.dumps(timeline)
|
||||
return render(request, 'timeline.html', context)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue