##// END OF EJS Templates
Load reflink previews of posts that are not present on the current page
Load reflink previews of posts that are not present on the current page

File last commit:

r322:6b051ab1 default
r354:34225dd7 default
Show More
board.py
22 lines | 565 B | text/x-python | PythonLexer
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