##// END OF EJS Templates
Split up post model into post and thread to normalise models. Still need some refactoring
Split up post model into post and thread to normalise models. Still need some refactoring

File last commit:

r322:6b051ab1 default
r398:b2448061 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