This commit is contained in:
j 2022-04-12 14:06:47 +01:00
parent 864c43987a
commit 596bf66df0
3 changed files with 29 additions and 1 deletions

View file

@ -1,3 +1,4 @@
from timeline import timeline
from django.db import models
from django.conf import settings
@ -29,6 +30,32 @@ class Event(models.Model):
def get_absolute_url(self):
return '/' + settings.URL_PREFIX + '#' + self.slug
def display_date(self):
date = self.date.split(' ')
start = date[0].split('-')
if len(date) > 1:
end = date[1].split('-')
else:
end = start
end_only_month = False
start_only_month = False
while len(end) < 3:
end.append(1)
end_only_month = True
while len(start) < 3:
start.append(1)
start_only_month = True
display_date = datetime*start).strftime('%d %B, $y')
if start_only_month:
display_date = ' '.join(display_date.split(' ')[1:])
if end != start:
end_date = datetime*end).strftime('%d %B, $y')
if end_only_month:
end_date = ' '.join(end_date.split(' ')[1:])
display_date += ''+ end_date
return display_date
def media_html(self):
html = ''
if self.media and self.media.split('.')[-1] in ('jpg', 'png', 'gif'):

View file

@ -58,6 +58,7 @@ def timeline(request):
"millisecond": "",
"format": ""
},
"display_date": event.display_date,
"text": {
"headline": event.title,
"text": event.body

View file

@ -14,7 +14,7 @@
{% for event in events %}
<div class="event" {% if event.date %}data-date="{{ event.date }}"{% endif %} id="{{ event.slug }}">
<h2 class="{{ event.type }}">{{ event.title | safe }}</h2>
<div class="date">{{ event.date }}</div>
<div class="date">{{ event.display_date }}</div>
{% if event.media %}
<div class="side-by-side">
<div class="media">