thread.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. {% extends "sora/layout.html" %}
  2. {% load i18n %}
  3. {% load url from future %}
  4. {% import "_forms.html" as form_theme with context %}
  5. {% import "sora/editor.html" as editor with context %}
  6. {% import "sora/macros.html" as macros with context %}
  7. {% block title %}{{ macros.page_title(title=thread.name,parent=forum.name,page=pagination['page']) }}{% endblock %}
  8. {% block breadcrumb %}{{ super() }} <span class="divider">/</span></li>
  9. {% for parent in parents %}
  10. <li><a href="{{ parent.type|url(forum=forum.pk, slug=forum.slug) }}">{{ parent.name }}</a> <span class="divider">/</span></li>
  11. {% endfor %}
  12. <li class="active">{{ thread.name }}
  13. {%- endblock %}
  14. {% block content %}
  15. <div class="page-header">
  16. <ul class="breadcrumb">
  17. {{ self.breadcrumb() }}</li>
  18. </ul>
  19. <h1>{{ thread.name }}</h1>
  20. <ul class="unstyled thread-info">
  21. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  22. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  23. <li><i class="icon-user"></i> {% if thread.start_poster_id %}<a href="{% url 'user' user=thread.start_poster_id, username=thread.start_poster_slug %}">{{ thread.start_poster_name }}</a>{% else %}{{ thread.start_poster_name }}{% endif %}</li>
  24. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  25. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  26. {%- else -%}
  27. {% trans %}No replies{% endtrans %}
  28. {%- endif %}</li>
  29. </ul>
  30. </div>
  31. {% if message %}{{ macros.draw_message(message) }}{% endif %}
  32. <div class="list-nav">
  33. {{ pager() }}
  34. {% if user.is_authenticated() %}
  35. <ul class="nav nav-pills pull-right">
  36. <li class="info"><a href="{% url 'thread_new' forum=forum.pk, slug=forum.slug %}"><i class="icon-ok"></i> {% trans %}Watch Thread{% endtrans %}</a></li>{% if acl.threads.can_reply(forum, thread) %}
  37. <li class="primary"><a href="{% url 'thread_reply' thread=thread.pk, slug=thread.slug %}"><i class="icon-plus"></i> {% trans %}Reply{% endtrans %}</a></li>{% endif %}
  38. </ul>
  39. {% endif %}
  40. </div>
  41. <div class="posts-list">
  42. {% for post in posts %}
  43. {% if post.message %}{{ macros.draw_message(post.message) }}{% endif %}
  44. {% if post.deleted and not acl.threads.can_see_deleted_posts(forum) %}
  45. <div id="post-{{ post.pk }}" class="well well-post well-post-deleted{% if post.user and post.user.rank and post.user.rank.style %} {{ post.user.rank.style }}{% endif %}">
  46. <div class="post-author">
  47. <div class="post-bit">
  48. {% if post.user_id %}
  49. <a href="{% url 'user' user=post.user.pk, username=post.user.username_slug %}" class="lead">{{ post.user.username }}</a>
  50. {% else %}
  51. <span class="lead">{{ post.user_name }}</span>
  52. {% endif %}
  53. </div>
  54. </div>
  55. <div class="post-extra">
  56. <a href="{% if pagination['page'] > 1 -%}
  57. {% url 'thread' thread=thread.pk, slug=thread.slug, page=pagination['page'] %}
  58. {%- else -%}
  59. {% url 'thread' thread=thread.pk, slug=thread.slug %}
  60. {%- endif %}#post-{{ post.pk }}" class="post-perma pull-right tooltip-left" title="{% trans %}Direct link to this post{% endtrans %}">#{{ pagination['start'] + loop.index }}</a>
  61. </div>
  62. <div class="post-content">
  63. {% trans user=edit_user(post), date=post.edit_date|reltimesince|low %}{{ user }} has deleted this reply {{ date }}{% endtrans %}
  64. </div>
  65. </div>
  66. {% else %}
  67. <div id="post-{{ post.pk }}" class="well well-post{% if post.user and post.user.rank and post.user.rank.style %} {{ post.user.rank.style }}{% endif %}">
  68. <div class="post-author">
  69. <img src="{% if post.user_id %}{{ post.user.get_avatar(80) }}{% else %}{{ macros.avatar_guest(80) }}{% endif %}" alt="" class="avatar-normal">
  70. <div class="post-bit">
  71. {% if post.user_id %}
  72. <a href="{% url 'user' user=post.user.pk, username=post.user.username_slug %}" class="lead">{{ post.user.username }}</a>
  73. {% if post.user.get_title() %}<p class="user-title">{{ _(post.user.get_title()) }}</p>{% endif %}
  74. {% else %}
  75. <span class="lead">{{ post.user_name }}</span>
  76. <p class="user-title">{% trans %}Unregistered{% endtrans %}</p>
  77. {% endif %}
  78. <p class="post-date">{{ post.date|reltimesince|low }}</p>
  79. </div>
  80. </div>
  81. <div class="post-extra">
  82. {% if user.is_authenticated() and posts_form %}
  83. <label class="checkbox post-checkbox"><input form="posts_form" name="{{ posts_form['list_items']['html_name'] }}" type="checkbox" class="checkbox-member" value="{{ post.pk }}"{% if posts_form['list_items']['has_value'] and ('' ~ post.pk) in posts_form['list_items']['value'] %} checked="checked"{% endif %}></label>
  84. {% endif %}
  85. <a href="{% if pagination['page'] > 1 -%}
  86. {% url 'thread' thread=thread.pk, slug=thread.slug, page=pagination['page'] %}
  87. {%- else -%}
  88. {% url 'thread' thread=thread.pk, slug=thread.slug %}
  89. {%- endif %}#post-{{ post.pk }}" class="post-perma pull-right tooltip-left" title="{% trans %}Direct link to this post{% endtrans %}">#{{ pagination['start'] + loop.index }}</a>
  90. {% if not post.is_read %}
  91. <span class="label label-warning pull-right">
  92. {% trans %}New{% endtrans %}
  93. </span>
  94. {% endif %}
  95. {% if post.moderated %}
  96. <span class="label label-purple pull-right">
  97. {% trans %}Unreviewed{% endtrans %}
  98. </span>
  99. {% endif %}
  100. {% if post.reported %}
  101. <span class="label label-important pull-right">
  102. {% trans %}Reported{% endtrans %}
  103. </span>
  104. {% endif %}
  105. {% if post.deleted %}
  106. <span class="label label-inverse pull-right">
  107. {% trans %}Deleted{% endtrans %}
  108. </span>
  109. {% endif %}
  110. {% if post.protected and acl.threads.can_protect(forum) %}
  111. <span class="label label-info pull-right">
  112. {% trans %}Protected{% endtrans %}
  113. </span>
  114. {% endif %}
  115. </div>
  116. <div class="post-content">
  117. <div class="markdown">
  118. {{ post.post_preparsed|safe }}
  119. </div>
  120. {% if post.user.signature %}
  121. <div class="post-foot">
  122. {# <p class='lead'><a href="{% url 'user' user=post.user.pk, username=post.user.username_slug %}" class="lead">{{ post.user.username }}</a>, {{ post.date|reltimesince|low }}</p> #}
  123. {% if post.user.signature %}
  124. <div class="signature">
  125. <div class="markdown">
  126. {{ post.user.signature_preparsed|safe }}
  127. </div>
  128. </div>
  129. {% endif %}
  130. </div>
  131. {% endif %}
  132. </div>
  133. <div class="post-nav">
  134. {% if post.edits %}
  135. {% if acl.threads.can_see_changelog(user, forum, post) %}
  136. <a href="{% url 'changelog' thread=thread.pk, slug=thread.slug, post=post.pk %}" class="changelog tooltip-bottom" title="{% trans %}Show changelog{% endtrans %}">{% trans count=post.edits %}One edit{% pluralize %}{{ count }} edits{% endtrans %}</a>
  137. {% else %}
  138. <span class="changelog">{% trans count=post.edits %}One edit{% pluralize %}{{ count }} edits{% endtrans %}</span>
  139. {% endif %}
  140. {% endif %}
  141. {% if user.is_authenticated() %}
  142. <ul class="nav nav-pills pull-right">
  143. {% if 1 == 2 %}
  144. <li><a href="#"><i class="icon-info-sign"></i> {% trans %}Info{% endtrans %}</a></li>
  145. {% endif %}
  146. {% if post.pk == thread.start_post_id %}
  147. {% if acl.threads.can_delete_thread(user, forum, thread, post) == 2 -%}
  148. <li class="tooltip-top" title="{% trans %}Delete this thread for good{% endtrans %}"><form action="{% url 'thread_delete' thread=thread.pk, slug=thread.slug %}" method="post"><button type="submit" class="btn danger"><i class="icon-remove"></i></button><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"></form></li>{% endif %}
  149. {% if not post.deleted and acl.threads.can_delete_thread(user, forum, thread, post) -%}
  150. <li><form action="{% url 'thread_hide' thread=thread.pk, slug=thread.slug %}" method="post"><button type="submit" class="btn danger"><i class="icon-trash"></i> {% trans %}Delete{% endtrans %}</button><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"></form></li>{% endif %}
  151. {% elif post.pk != thread.start_post_id and acl.threads.can_delete_post(user, forum, thread, post) %}
  152. {% if acl.threads.can_delete_post(user, forum, thread, post) == 2 -%}
  153. <li class="tooltip-top" title="{% trans %}Delete this reply for good{% endtrans %}"><form action="{% url 'post_delete' thread=thread.pk, slug=thread.slug, post=post.pk %}" method="post"><button type="submit" class="btn danger"><i class="icon-remove"></i></button><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"></form></li>{% endif %}
  154. {% if not post.deleted and acl.threads.can_delete_post(user, forum, thread, post) -%}
  155. <li><form action="{% url 'post_hide' thread=thread.pk, slug=thread.slug, post=post.pk %}" method="post"><button type="submit" class="btn danger"><i class="icon-trash"></i> {% trans %}Delete{% endtrans %}</button><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"></form></li>{% endif %}
  156. {% endif %}
  157. {% if acl.threads.can_edit_thread(user, forum, thread, post) and thread.start_post_id == post.pk -%}
  158. <li><a href="{% url 'thread_edit' thread=thread.pk, slug=thread.slug %}"><i class="icon-edit"></i> {% trans %}Edit{% endtrans %}</a></li>
  159. {% elif acl.threads.can_edit_reply(user, forum, thread, post) %}
  160. <li><a href="{% url 'post_edit' thread=thread.pk, slug=thread.slug, post=post.pk %}"><i class="icon-edit"></i> {% trans %}Edit{% endtrans %}</a></li>
  161. {%- endif %}
  162. {% if acl.threads.can_reply(forum, thread) %}<li><a href="{% url 'thread_reply' thread=thread.pk, slug=thread.slug, quote=post.pk %}"><i class="icon-comment"></i> {% trans %}Reply{% endtrans %}</a></li>{% endif %}
  163. </ul>
  164. {% endif %}
  165. </div>
  166. </div>
  167. {% endif %}
  168. {% if post.checkpoint_set.all() %}
  169. <div class="post-checkpoints">
  170. {% for checkpoint in post.checkpoint_set.all() %}
  171. <div class="checkpoint">
  172. <hr>
  173. <span>
  174. {%- if checkpoint.action == 'limit' -%}
  175. <i class="icon-lock"></i> {% trans %}This thread has reached its post limit and has been closed.{% endtrans %}
  176. {%- elif checkpoint.action == 'accepted' -%}
  177. <i class="icon-ok"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} accepted this thread {{ date }}{% endtrans %}
  178. {%- elif checkpoint.action == 'closed' -%}
  179. <i class="icon-lock"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} closed this thread {{ date }}{% endtrans %}
  180. {%- elif checkpoint.action == 'opened' -%}
  181. <i class="icon-lock"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} opened this thread {{ date }}{% endtrans %}
  182. {%- elif checkpoint.action == 'deleted' -%}
  183. <i class="icon-trash"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} deleted this thread {{ date }}{% endtrans %}
  184. {%- elif checkpoint.action == 'undeleted' -%}
  185. <i class="icon-trash"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} restored this thread {{ date }}{% endtrans %}
  186. {%- endif -%}
  187. </span>
  188. </div>
  189. {% endfor %}
  190. </div>
  191. {% endif %}
  192. {% endfor %}
  193. </div>
  194. {% if user.is_authenticated() and (thread_form or posts_form) %}
  195. <div class="form-actions table-footer mod-actions">
  196. {% if thread_form%}
  197. <form id="thread_form" class="form-inline pull-left" action="{% url 'thread' slug=thread.slug, thread=thread.id, page=pagination['page'] %}" method="POST">
  198. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  199. <input type="hidden" name="origin" value="thread_form">
  200. {{ form_theme.input_select(thread_form['thread_action'],width=3) }}
  201. <button type="submit" class="btn btn-primary">{% trans %}Go{% endtrans %}</button>
  202. </form>
  203. {% endif %}
  204. {% if posts_form%}
  205. <form id="posts_form" class="form-inline pull-right" action="{% url 'thread' slug=thread.slug, thread=thread.id, page=pagination['page'] %}" method="POST">
  206. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  207. <input type="hidden" name="origin" value="posts_form">
  208. {{ form_theme.input_select(posts_form['list_action'],width=3) }}
  209. <button type="submit" class="btn btn-primary">{% trans %}Go{% endtrans %}</button>
  210. </form>
  211. {% endif %}
  212. </div>
  213. {% endif %}
  214. <div class="list-nav last">
  215. {{ pager(false) }}
  216. {% if user.is_authenticated() and acl.threads.can_reply(forum, thread) %}
  217. <ul class="nav nav-pills pull-right">
  218. <li class="primary"><a href="{% url 'thread_reply' thread=thread.pk, slug=thread.slug %}"><i class="icon-plus"></i> {% trans %}Reply{% endtrans %}</a></li>
  219. </ul>
  220. {% endif %}
  221. </div>
  222. {% if user.is_authenticated() and acl.threads.can_reply(forum, thread) %}
  223. <div class="quick-reply">
  224. <form action="{% url 'thread_reply' thread=thread.pk, slug=thread.slug %}" method="post">
  225. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  226. <input type="hidden" name="quick_reply" value="1">
  227. <img src="{{ user.get_avatar() }}" alt="{% trans %}Your Avatar{% endtrans %}" class="avatar-big">
  228. <div class="arrow"></div>
  229. {{ editor.editor(quick_reply.post, _('Post Reply')) }}
  230. </form>
  231. </div>
  232. {% endif %}
  233. {% endblock %}
  234. {% macro pager(extra=true) %}
  235. <ul class="pager pull-left">
  236. {%- if pagination['prev'] > 1 %}<li><a href="{% url 'thread' slug=thread.slug, thread=thread.id %}" class="tooltip-top" title="{% trans %}Go to first page{% endtrans %}"><i class="icon-chevron-left"></i> {% trans %}First{% endtrans %}</a></li>{% endif -%}
  237. {%- if pagination['prev'] > 0 %}<li><a href="{%- if pagination['prev'] > 1 %}{% url 'thread' slug=thread.slug, thread=thread.id, page=pagination['prev'] %}{% else %}{% url 'thread' slug=thread.slug, thread=thread.id %}{% endif %}" class="tooltip-top" title="{% trans %}Older Posts{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
  238. {%- if pagination['next'] > 0 %}<li><a href="{% url 'thread' slug=thread.slug, thread=thread.id, page=pagination['next'] %}" class="tooltip-top" title="{% trans %}Newest Posts{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  239. {%- if pagination['next'] > 0 and pagination['next'] < pagination['total'] %}<li><a href="{% url 'thread' slug=thread.slug, thread=thread.id, page=pagination['total'] %}" class="tooltip-top" title="{% trans %}Go to last page{% endtrans %}">{% trans %}Last{% endtrans %} <i class="icon-chevron-right"></i></a></li>{% endif -%}
  240. <li class="count">
  241. {%- trans current_page=pagination['page'], pages=pagination['total'] -%}
  242. Page {{ current_page }} of {{ pages }}
  243. {%- endtrans -%}
  244. </li>
  245. {% if extra and user.is_authenticated() %}
  246. {% if not is_read %}<li class="unread"><a href="{% url 'thread_new' slug=thread.slug, thread=thread.id %}" class="tooltip-top" title="{% trans %}Go to first unread{% endtrans %}"><i class="icon-star"></i> {% trans %}First Unread{% endtrans %}</a></li>{% endif %}
  247. {% if thread.replies_moderated > 0 and acl.threads.can_approve(forum) %}<li class="moderated"><a href="{% url 'thread_moderated' slug=thread.slug, thread=thread.id %}" class="tooltip-top" title="{% trans %}Go to first post awaiting review{% endtrans %}"><i class="icon-eye-close"></i> {% trans %}First Unreviewed{% endtrans %}</a></li>{% endif %}
  248. {% if thread.replies_reported > 0 and acl.threads.can_mod_posts(thread) %}<li class="reported"><a href="{% url 'thread_reported' slug=thread.slug, thread=thread.id %}" class="tooltip-top" title="{% trans %}Go to first reported post{% endtrans %}"><i class="icon-fire"></i> {% trans %}First Reported{% endtrans %}</a></li>{% endif %}
  249. {% endif %}
  250. </ul>
  251. {% endmacro %}
  252. {% macro checkpoint_user(checkpoint) -%}
  253. {%- if checkpoint.user_id -%}
  254. {{ ('<a href="' ~ 'user'|url(user=checkpoint.user_id, username=checkpoint.user_slug) ~ '">')|safe ~ (checkpoint.user_name) ~ ("</a>")|safe }}
  255. {%- else -%}
  256. <strong>{{ checkpoint.user_name }}</strong>
  257. {%- endif -%}
  258. {%- endmacro %}
  259. {% macro edit_user(post) -%}
  260. {%- if post.edit_user_id -%}
  261. {{ ('<a href="' ~ 'user'|url(user=post.edit_user_id, username=post.edit_user_slug) ~ '">')|safe ~ (post.edit_user_name) ~ ("</a>")|safe }}
  262. {%- else -%}
  263. <strong>{{ post.edit_user_name }}</strong>
  264. {%- endif -%}
  265. {%- endmacro %}
  266. {% block javascripts -%}
  267. {{ super() }}
  268. {%- if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  269. <script type="text/javascript">
  270. $(function () {
  271. $('#thread_form').submit(function() {
  272. if ($('#id_thread_action').val() == 'hard') {
  273. var decision = confirm("{% trans %}Are you sure you want to delete this thread? This action is not reversible!{% endtrans %}");
  274. return decision;
  275. }
  276. return true;
  277. });
  278. $('#posts_form').submit(function() {
  279. if ($('.post-checkbox[]:checked').length == 0) {
  280. alert("{% trans %}You have to select at least one post.{% endtrans %}");
  281. return false;
  282. }
  283. if ($('#id_list_action').val() == 'merge') {
  284. if ($('.post-checkbox[]:checked').length < 2) {
  285. alert("{% trans %}You have to select at least two posts you want to merge.{% endtrans %}");
  286. return false;
  287. }
  288. var decision = confirm("{% trans %}Are you sure you want to merge selected posts? This action is not reversible!{% endtrans %}");
  289. return decision;
  290. }
  291. if ($('#id_list_action').val() == 'hard') {
  292. var decision = confirm("{% trans %}Are you sure you want to delete selected posts? This action is not reversible!{% endtrans %}");
  293. return decision;
  294. }
  295. return true;
  296. });
  297. });
  298. </script>{% endif %}
  299. {%- endblock %}