add media

This commit is contained in:
j 2021-11-19 15:22:59 +01:00
parent c2f521095e
commit a59093d7d2
3 changed files with 24 additions and 4 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2021-11-19 14:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('event', '0005_event_media'),
]
operations = [
migrations.AddField(
model_name='event',
name='media_caption',
field=models.TextField(blank=True, default='', null=True),
),
]

View file

@ -19,6 +19,7 @@ class Event(models.Model):
date = models.CharField(blank=True, null=True, max_length=1024) date = models.CharField(blank=True, null=True, max_length=1024)
body = models.TextField(blank=True, null=True) body = models.TextField(blank=True, null=True)
media = models.TextField(blank=True, null=True) media = models.TextField(blank=True, null=True)
media_caption = models.TextField(blank=True, null=True, default='')
data = models.JSONField(default=dict, blank=True, editable=False) data = models.JSONField(default=dict, blank=True, editable=False)

View file

@ -57,15 +57,16 @@ def timeline(request):
"millisecond": "", "millisecond": "",
"format": "" "format": ""
}, },
#"media": {
# "caption": event.title,
# "credit": "",
#},
"text": { "text": {
"headline": event.title, "headline": event.title,
"text": event.body "text": event.body
}, },
"unique_id": event.slug "unique_id": event.slug
}) })
if self.media:
timeline['events'][-1]['media'] = {
"url": self.media,
"caption": self.media_caption,
}
context['timeline_json'] = json.dumps(timeline) context['timeline_json'] = json.dumps(timeline)
return render(request, 'timeline.html', context) return render(request, 'timeline.html', context)