##// END OF EJS Templates
Reflinks to OPs are bold now. Refactored reflinks to build using the same code. Refactored autoescaping
neko259 -
r1309:a2eaff61 default
parent child Browse files
Show More
@@ -0,0 +1,21 b''
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 from django.db import migrations
5 from boards.models import Post
6
7
8 class Migration(migrations.Migration):
9
10 def refuild_refmap(apps, schema_editor):
11 for post in Post.objects.all():
12 post.build_refmap()
13 post.save(update_fields=['refmap'])
14
15 dependencies = [
16 ('boards', '0024_post_tripcode'),
17 ]
18
19 operations = [
20 migrations.RunPython(refuild_refmap),
21 ]
@@ -130,7 +130,7 b' def render_reflink(tag_name, value, opti'
130 130 try:
131 131 post = boards.models.Post.objects.get(id=post_id)
132 132
133 result = '<a href="%s">&gt;&gt;%s</a>' % (post.get_absolute_url(), post_id)
133 result = post.get_link_view()
134 134 except ObjectDoesNotExist:
135 135 pass
136 136
@@ -61,8 +61,6 b' POST_VIEW_PARAMS = ('
61 61 'mode_tree',
62 62 )
63 63
64 REFMAP_STR = '<a href="{}">&gt;&gt;{}</a>'
65
66 64 IMAGE_TYPES = (
67 65 'jpeg',
68 66 'jpg',
@@ -230,7 +228,7 b' class Post(models.Model, Viewable):'
230 228 the server from recalculating the map on every post show.
231 229 """
232 230
233 post_urls = [REFMAP_STR.format(refpost.get_absolute_url(), refpost.id)
231 post_urls = [refpost.get_link_view()
234 232 for refpost in self.referenced_posts.all()]
235 233
236 234 self.refmap = ', '.join(post_urls)
@@ -444,3 +442,15 b' class Post(models.Model, Viewable):'
444 442 def get_tripcode(self):
445 443 if self.tripcode:
446 444 return Tripcode(self.tripcode)
445
446 def get_link_view(self):
447 """
448 Gets view of a reflink to the post.
449 """
450
451 result = '<a href="{}">&gt;&gt;{}</a>'.format(self.get_absolute_url(),
452 self.id)
453 if self.is_opening():
454 result = '<b>{}</b>'.format(result)
455
456 return result
@@ -64,25 +64,19 b''
64 64 <button name="method" value="hide" class="not_fav">H</button>
65 65 {% endif %}
66 66 </form>
67 {% autoescape off %}
68 {{ tag.get_view }}
69 {% endautoescape %}
67 {{ tag.get_view|safe }}
70 68 {% if moderator %}
71 69 <span class="moderator_info">| <a href="{% url 'admin:boards_tag_change' tag.id %}">{% trans 'Edit tag' %}</a></span>
72 70 {% endif %}
73 71 </h2>
74 72 {% if tag.get_description %}
75 {% autoescape off %}
76 <p>{{ tag.get_description }}</p>
77 {% endautoescape %}
73 <p>{{ tag.get_description|safe }}</p>
78 74 {% endif %}
79 75 <p>{% blocktrans with active_thread_count=tag.get_active_thread_count thread_count=tag.get_thread_count post_count=tag.get_post_count %}This tag has {{ thread_count }} threads ({{ active_thread_count}} active) and {{ post_count }} posts.{% endblocktrans %}</p>
80 76 {% if related_tags %}
81 77 <p>{% trans 'Related tags:' %}
82 78 {% for rel_tag in related_tags %}
83 {% autoescape off %}
84 {{ rel_tag.get_view }}{% if not forloop.last %}, {% else %}.{% endif %}
85 {% endautoescape %}
79 {{ rel_tag.get_view|safe }}{% if not forloop.last %}, {% else %}.{% endif %}
86 80 {% endfor %}
87 81 </p>
88 82 {% endif %}
@@ -36,7 +36,7 b''
36 36 {% else %}
37 37 {% if need_op_data %}
38 38 {% with thread.get_opening_post as op %}
39 {% trans " in " %}<a href="{{ op.get_absolute_url }}">&gt;&gt;{{ op.id }}</a> <span class="title">{{ op.get_title|striptags|truncatewords:5 }}</span>
39 {% trans " in " %}{{ op.get_link_view|safe }} <span class="title">{{ op.get_title|striptags|truncatewords:5 }}</span>
40 40 {% endwith %}
41 41 {% endif %}
42 42 {% endif %}
@@ -59,16 +59,12 b''
59 59 {% endcomment %}
60 60 {% if post.images.exists %}
61 61 {% with post.images.first as image %}
62 {% autoescape off %}
63 {{ image.get_view }}
64 {% endautoescape %}
62 {{ image.get_view|safe }}
65 63 {% endwith %}
66 64 {% endif %}
67 65 {% if post.attachments.exists %}
68 66 {% with post.attachments.first as file %}
69 {% autoescape off %}
70 {{ file.get_view }}
71 {% endautoescape %}
67 {{ file.get_view|safe }}
72 68 {% endwith %}
73 69 {% endif %}
74 70 {% comment %}
@@ -92,9 +88,7 b''
92 88 </div>
93 89 {% else %}
94 90 <div class="refmap">
95 {% autoescape off %}
96 {% trans "Replies" %}: {{ post.refmap }}
97 {% endautoescape %}
91 {% trans "Replies" %}: {{ post.refmap|safe }}
98 92 </div>
99 93 {% endif %}
100 94 {% endif %}
@@ -108,9 +102,7 b''
108 102 {{ thread.get_images_count }} {% trans 'images' %}.
109 103 {% endif %}
110 104 <span class="tags">
111 {% autoescape off %}
112 {{ thread.get_tag_url_list }}
113 {% endautoescape %}
105 {{ thread.get_tag_url_list|safe }}
114 106 </span>
115 107 </div>
116 108 {% endif %}
@@ -18,9 +18,7 b''
18 18 {% if hidden_tags %}
19 19 <p>{% trans 'Hidden tags:' %}
20 20 {% for tag in hidden_tags %}
21 {% autoescape off %}
22 {{ tag.get_view }}
23 {% endautoescape %}
21 {{ tag.get_view|safe }}
24 22 {% endfor %}
25 23 </p>
26 24 {% else %}
@@ -1,5 +1,3 b''
1 1 <div class="post">
2 {% autoescape off %}
3 {{ tag.get_view }}
4 {% endautoescape %}
2 {{ tag.get_view|safe }}
5 3 </div>
General Comments 0
You need to be logged in to leave comments. Login now