Show More
@@ -1,22 +1,22 b'' | |||||
1 | from django.core.urlresolvers import reverse |
|
1 | from django.core.urlresolvers import reverse | |
2 | from django.shortcuts import get_object_or_404 |
|
2 | from django.shortcuts import get_object_or_404 | |
3 | from boards.models import Post |
|
3 | from boards.models import Post | |
4 | from boards.views import thread |
|
4 | from boards.views import thread | |
5 | from django import template |
|
5 | from django import template | |
6 |
|
6 | |||
7 | register = template.Library() |
|
7 | register = template.Library() | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | @register.simple_tag(name='post_url') |
|
10 | @register.simple_tag(name='post_url') | |
11 | def post_url(*args, **kwargs): |
|
11 | def post_url(*args, **kwargs): | |
12 | post_id = args[0] |
|
12 | post_id = args[0] | |
13 |
|
13 | |||
14 | post = get_object_or_404(Post, id=post_id) |
|
14 | post = get_object_or_404(Post, id=post_id) | |
15 |
|
15 | |||
16 | if post.thread: |
|
16 | if post.thread: | |
17 |
|
|
17 | link = reverse(thread, kwargs={'post_id': post.thread.id}) \ | |
18 |
|
|
18 | + '#' + str(post_id) | |
19 | else: |
|
19 | else: | |
20 |
|
|
20 | link = reverse(thread, kwargs={'post_id': post_id}) | |
21 |
|
21 | |||
22 | return link |
|
22 | return link |
General Comments 0
You need to be logged in to leave comments.
Login now