From 8a8abd33fffeaf22f474981ec28ae6779149cf8c Mon Sep 17 00:00:00 2001 From: j Date: Fri, 19 Nov 2021 15:31:23 +0100 Subject: [PATCH] render media --- app/event/models.py | 11 +++++++++++ app/templates/index.html | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/event/models.py b/app/event/models.py index 7dccfdf..46c751b 100644 --- a/app/event/models.py +++ b/app/event/models.py @@ -21,6 +21,7 @@ class Event(models.Model): 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) def __str__(self): @@ -28,3 +29,13 @@ class Event(models.Model): def get_absolute_url(self): return '/' + settings.URL_PREFIX + '#' + self.slug + + def media_html(self): + html = '' + if self.media and self.media.split('.')[-1] in ('jpg', 'png', 'gif'): + html += '' % self.media + else: + html += '' % self.media + if self.media_caption: + html = '
%s
%s
' % (html, self.media_caption) + return html diff --git a/app/templates/index.html b/app/templates/index.html index 5277932..6bf8efe 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -13,7 +13,8 @@ {% if event.media %}
- {{ event.media | safe }} + + {{ event.media_html | safe }}
{{ event.body | safe }}