From a59093d7d259ed68130e2e77ea74bd598a69fa5d Mon Sep 17 00:00:00 2001 From: j Date: Fri, 19 Nov 2021 15:22:59 +0100 Subject: [PATCH] add media --- .../migrations/0006_event_media_caption.py | 18 ++++++++++++++++++ app/event/models.py | 1 + app/event/views.py | 9 +++++---- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 app/event/migrations/0006_event_media_caption.py diff --git a/app/event/migrations/0006_event_media_caption.py b/app/event/migrations/0006_event_media_caption.py new file mode 100644 index 0000000..2af0f94 --- /dev/null +++ b/app/event/migrations/0006_event_media_caption.py @@ -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), + ), + ] diff --git a/app/event/models.py b/app/event/models.py index 5fe1123..eceb77c 100644 --- a/app/event/models.py +++ b/app/event/models.py @@ -19,6 +19,7 @@ class Event(models.Model): date = models.CharField(blank=True, null=True, max_length=1024) body = 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) diff --git a/app/event/views.py b/app/event/views.py index 00c74e0..194b6ca 100644 --- a/app/event/views.py +++ b/app/event/views.py @@ -57,15 +57,16 @@ def timeline(request): "millisecond": "", "format": "" }, - #"media": { - # "caption": event.title, - # "credit": "", - #}, "text": { "headline": event.title, "text": event.body }, "unique_id": event.slug }) + if self.media: + timeline['events'][-1]['media'] = { + "url": self.media, + "caption": self.media_caption, + } context['timeline_json'] = json.dumps(timeline) return render(request, 'timeline.html', context)