Show More
@@ -34,11 +34,20 b' class QuotePattern(Pattern):' | |||||
34 |
|
34 | |||
35 | class ReflinkPattern(Pattern): |
|
35 | class ReflinkPattern(Pattern): | |
36 | def handleMatch(self, m): |
|
36 | def handleMatch(self, m): | |
37 | ref_element = etree.Element('a') |
|
|||
38 | post_id = m.group(4) |
|
37 | post_id = m.group(4) | |
39 | ref_element.set('href', reverse(boards.views.jump_to_post, |
|
38 | ||
40 | kwargs={'post_id': post_id})) |
|
39 | post = Post.objects.filter(id=post_id) | |
41 | ref_element.text = m.group(2) |
|
40 | if post: | |
|
41 | ref_element = etree.Element('a') | |||
|
42 | ||||
|
43 | if post.thread: | |||
|
44 | link = reverse(thread, kwargs={'post_id': post.thread.id}) | |||
|
45 | + '#' + post_id) | |||
|
46 | else: | |||
|
47 | link = reverse(thread, post_id=post_id) | |||
|
48 | ||||
|
49 | ref_element.set('href', link) | |||
|
50 | ref_element.text = m.group(2) | |||
42 |
|
51 | |||
43 | return ref_element |
|
52 | return ref_element | |
44 |
|
53 |
General Comments 0
You need to be logged in to leave comments.
Login now