From 9164f13c6a627d904a66600468f73bdba808fc71 Mon Sep 17 00:00:00 2001 From: andis Date: Wed, 26 Aug 2020 20:11:57 +0000 Subject: [PATCH] layout events --- fet2020/fet2020/views.py | 2 +- fet2020/posts/models.py | 11 ++++++++++- fet2020/templates/layout.html | 7 +++++-- fet2020/templates/posts/partials/_date_box.html | 4 ++-- fet2020/templates/posts/show.html | 17 ++++++++++++----- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/fet2020/fet2020/views.py b/fet2020/fet2020/views.py index cae104b9..4e020e00 100644 --- a/fet2020/fet2020/views.py +++ b/fet2020/fet2020/views.py @@ -20,7 +20,7 @@ def index(request): context = { 'posts': posts, - 'events': Event.objects.get_all_events(), + 'events': Event.objects.order_by("-event_start").all(), 'featured_post': featured_post, 'featured_post2': FetMeeting.objects.first(), 'tags_list': ", ".join(t) diff --git a/fet2020/posts/models.py b/fet2020/posts/models.py index 495d44ec..8ca3ddf3 100644 --- a/fet2020/posts/models.py +++ b/fet2020/posts/models.py @@ -145,6 +145,10 @@ class Post(models.Model): """Returns assigned tags as a comma seperated list.""" return ",".join(self.tags.names()) + @property + def get_tagnames(self): + return ["#%s" % t for t in self.tags.names()] + def imageurl(self): """ returns the url to the image""" if self.image: @@ -231,7 +235,12 @@ class Event(Post): class Meta: proxy = True - + @property + def event_start_month (self): + return self.event_start.strftime("%b") + @property + def event_start_day(self): + return self.event_start.strftime("%d") def save(self, *args, **kwargs): self.is_event = True diff --git a/fet2020/templates/layout.html b/fet2020/templates/layout.html index f98c89bf..a6d0e674 100644 --- a/fet2020/templates/layout.html +++ b/fet2020/templates/layout.html @@ -28,10 +28,13 @@ - - {% block content %} {% endblock %} +
+
+admin +
+
diff --git a/fet2020/templates/posts/partials/_date_box.html b/fet2020/templates/posts/partials/_date_box.html index 4b3bc547..a57b8307 100644 --- a/fet2020/templates/posts/partials/_date_box.html +++ b/fet2020/templates/posts/partials/_date_box.html @@ -2,8 +2,8 @@
- 16 - Apr + {{post.event_start_day}} + {{post.event_start_month}} {{post.title}} diff --git a/fet2020/templates/posts/show.html b/fet2020/templates/posts/show.html index c481ade1..9d06e77c 100644 --- a/fet2020/templates/posts/show.html +++ b/fet2020/templates/posts/show.html @@ -36,10 +36,17 @@
{{post.body | safe}}
-tags:{{ post.get_tags }} - +{% for tag in post.get_tagnames %} +{{tag |tags_to_url}} +{% endfor %}
- -{{related_posts}} +
+ +{% for post in related_posts %} +
+ {% include 'posts/partials/_posts_hero.html' %} +
+ {% endfor %}
-{% endblock %} \ No newline at end of file +
+{% endblock %}fffsdfag \ No newline at end of file