add previous post
This commit is contained in:
@@ -202,6 +202,7 @@ def show(request, id=None):
|
|||||||
"author": author,
|
"author": author,
|
||||||
"author_image": author_image,
|
"author_image": author_image,
|
||||||
"next": __next(post, public_only),
|
"next": __next(post, public_only),
|
||||||
|
"previous": get_previous_dict(p),
|
||||||
"related_posts": related_posts[0:6],
|
"related_posts": related_posts[0:6],
|
||||||
"ep_agenda_link": ep_agenda_link,
|
"ep_agenda_link": ep_agenda_link,
|
||||||
"ep_protocol_link": ep_protocol_link,
|
"ep_protocol_link": ep_protocol_link,
|
||||||
@@ -282,3 +283,27 @@ def __next(post=None, public=True):
|
|||||||
break
|
break
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
def get_previous_dict(post=None):
|
||||||
|
# TODO: Docstring
|
||||||
|
posts = None
|
||||||
|
d = post.slug
|
||||||
|
|
||||||
|
if post:
|
||||||
|
# TODO: bad implementation but it works!!
|
||||||
|
if post.post_type == "N" or post.post_type == "E":
|
||||||
|
posts = Post.articles.get_visible_articles()
|
||||||
|
elif post.post_type == "F":
|
||||||
|
posts = FetMeeting.objects.get_queryset().order_by("-event_start")
|
||||||
|
|
||||||
|
if posts:
|
||||||
|
for k, v in enumerate(posts):
|
||||||
|
if post.slug == v.slug:
|
||||||
|
if k < 1:
|
||||||
|
d = posts[len(posts) - 1].slug
|
||||||
|
else:
|
||||||
|
d = posts[k - 1].slug
|
||||||
|
break
|
||||||
|
|
||||||
|
return d
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<!-- Main Content -->
|
<!-- Main Content -->
|
||||||
<main class="container mx-auto w-full flex-1 my-8 sm:flex flex-col sm:px-4">
|
<main class="container mx-auto w-full flex-1 my-8 sm:flex flex-col sm:px-4">
|
||||||
<a href="#" class="hidden z-20 fixed left-0 top-1/2 -mt-8 p-2 xl:flex items-center text-gray-400 dark:text-gray-300 rounded-md"
|
<a href="{% url 'posts:posts.show' previous %}" class="hidden z-20 fixed left-0 top-1/2 -mt-8 p-2 xl:flex items-center text-gray-400 dark:text-gray-300 rounded-md"
|
||||||
x-data="{ showPrevArticleButton : false }"
|
x-data="{ showPrevArticleButton : false }"
|
||||||
@mouseleave="showPrevArticleButton = false"
|
@mouseleave="showPrevArticleButton = false"
|
||||||
@mouseover="showPrevArticleButton = true"
|
@mouseover="showPrevArticleButton = true"
|
||||||
|
|||||||
Reference in New Issue
Block a user