diff --git a/boards/templates/boards/posting_general.html b/boards/templates/boards/posting_general.html --- a/boards/templates/boards/posting_general.html +++ b/boards/templates/boards/posting_general.html @@ -3,6 +3,7 @@ {% load i18n %} {% load markup %} {% load cache %} +{% load board %} {% block head %} {% if tag %} @@ -77,7 +78,7 @@
{% trans "Replies" %}: {% for ref_post in thread.thread.referenced_posts.all %} - >>{{ ref_post.id }} + >>{{ ref_post.id }} {% endfor %}
{% endif %} @@ -131,7 +132,7 @@
{% trans "Replies" %}: {% for ref_post in post.referenced_posts.all %} - >>{{ ref_post.id }} + >>{{ ref_post.id }} {% endfor %}
{% endif %} diff --git a/boards/templates/boards/thread.html b/boards/templates/boards/thread.html --- a/boards/templates/boards/thread.html +++ b/boards/templates/boards/thread.html @@ -4,6 +4,7 @@ {% load markup %} {% load cache %} {% load static from staticfiles %} +{% load board %} {% block head %} Neboard - {{ posts.0.get_title }} @@ -70,7 +71,7 @@
{% trans "Replies" %}: {% for ref_post in post.referenced_posts.all %} - >>{{ ref_post.id }} + >>{{ ref_post.id }} {% endfor %}
{% endif %} diff --git a/boards/templatetags/__init__.py b/boards/templatetags/__init__.py new file mode 100644 diff --git a/boards/templatetags/board.py b/boards/templatetags/board.py new file mode 100644 --- /dev/null +++ b/boards/templatetags/board.py @@ -0,0 +1,22 @@ +from django.core.urlresolvers import reverse +from django.shortcuts import get_object_or_404 +from boards.models import Post +from boards.views import thread +from django import template + +register = template.Library() + + +@register.simple_tag(name='post_url') +def post_url(*args, **kwargs): + post_id = args[0] + + post = get_object_or_404(Post, id=post_id) + + if post.thread: + link = reverse(thread, kwargs={'post_id': post.thread.id}) \ + + '#' + str(post_id) + else: + link = reverse(thread, kwargs={'post_id': post_id}) + + return link