list.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. {% extends "cranefly/layout.html" %}
  2. {% import "_forms.html" as form_theme with context %}
  3. {% import "cranefly/macros.html" as macros with context %}
  4. {% block title %}{{ macros.page_title(title=_("Private Threads"),page=pagination['page']) }}{% endblock %}
  5. {% block breadcrumb %}{{ super() }} <span class="divider"><i class="icon-chevron-right"></i></span></li>
  6. {% for parent in parents %}
  7. <li><a href="{{ parent.type|url(forum=parent.pk, slug=parent.slug) }}">{{ parent.name }}</a> <span class="divider"><i class="icon-chevron-right"></i></span></li>
  8. {% endfor %}
  9. <li class="active">{% trans %}Private Threads{% endtrans %}
  10. {%- endblock %}
  11. {% block container %}
  12. <div class="page-header header-primary">
  13. <div class="container">
  14. {{ messages_list(messages) }}
  15. <ul class="breadcrumb" {{ macros.itemprop_bread() }}>
  16. {{ self.breadcrumb() }}</li>
  17. </ul>
  18. <h1>{% trans %}Private Threads{% endtrans %}</h1>
  19. <ul class="nav nav-tabs header-tabs">
  20. <li class="{% if tab == 'all' %}active{% endif %}"><a href="{% url 'private_threads' %}">{% trans %}All Threads{% endtrans %}</a></li>
  21. <li class="{% if tab == 'new' %}active{% endif %}"><a href="{% url 'new_private_threads' %}">{% trans %}Unread Threads{% endtrans %}</a></li>
  22. <li class="{% if tab == 'my' %}active{% endif %}"><a href="{% url 'my_private_threads' %}">{% trans %}My Threads{% endtrans %}</a></li>
  23. </ul>
  24. </div>
  25. </div>
  26. <div class="container container-primary">
  27. {% if message %}
  28. <div class="messages-list">
  29. {{ macros.draw_message(message) }}
  30. </div>
  31. {% endif %}
  32. <div class="forum-threads-extra extra-top">
  33. {{ pager() }}
  34. {% if acl.threads.can_start_threads(forum) %}
  35. <a href="{% url 'private_thread_start' %}" class="btn btn-inverse pull-right"><i class="icon-plus"></i> {% trans %}New Thread{% endtrans %}</a>
  36. {% endif %}
  37. </div>
  38. <div class="forum-threads-list">
  39. <table class="table">
  40. <thead>
  41. <tr>
  42. <th>{% trans %}Thread{% endtrans %}</th>
  43. <th class="span1">{% trans %}Rating{% endtrans %}</th>
  44. <th class="span5">{% trans %}Activity{% endtrans %}</th>
  45. {% if list_form %}
  46. <th class="check-cell"><label class="checkbox"><input type="checkbox" class="checkbox-master"></label></th>
  47. {% endif %}
  48. </tr>
  49. </thead>
  50. <tbody>
  51. {% for thread in threads %}
  52. <tr>
  53. <td>
  54. <a href="{% url 'private_thread_new' thread=thread.pk, slug=thread.slug %}" class="thread-icon{% if not thread.is_read %} thread-new{% endif %} tooltip-top" title="{% if not thread.is_read -%}
  55. {% trans %}Click to see first unread post{% endtrans %}
  56. {%- else -%}
  57. {% trans %}Click to see last post{% endtrans %}
  58. {%- endif %}"><i class="icon-comment"></i></a>
  59. <a href="{% url 'private_thread' thread=thread.pk, slug=thread.slug %}" class="thread-name">{{ thread.name }}</a>
  60. <span class="thread-details">
  61. {% trans user=thread_starter(thread), start=thread.start|reldate|low %}by {{ user }} {{ start }}{% endtrans %}
  62. </span>
  63. <ul class="unstyled thread-flags">
  64. {% if thread.replies_reported %}
  65. <li><i class="icon-warning-sign tooltip-top" title="{% trans %}This thread has reported replies{% endtrans %}"></i></li>
  66. {% endif %}
  67. {% if thread.replies_moderated %}
  68. <li><i class="icon-question-sign tooltip-top" title="{% trans %}This thread has unreviewed replies{% endtrans %}"></i></li>
  69. {% endif %}
  70. {% if thread.weight == 2 %}
  71. <li><i class="icon-star tooltip-top" title="{% trans %}This thread is an annoucement{% endtrans %}"></i></li>
  72. {% endif %}
  73. {% if thread.weight == 1 %}
  74. <li><i class="icon-star-empty tooltip-top" title="{% trans %}This thread is sticky{% endtrans %}"></i></li>
  75. {% endif %}
  76. {% if thread.moderated %}
  77. <li><i class="icon-eye-close tooltip-top" title="{% trans %}This thread awaits review{% endtrans %}"></i></li>
  78. {% endif %}
  79. {% if thread.deleted %}
  80. <li><i class="icon-trash tooltip-top" title="{% trans %}This thread is deleted{% endtrans %}"></i></li>
  81. {% endif %}
  82. {% if thread.closed %}
  83. <li><i class="icon-lock tooltip-top" title="{% trans %}This thread is closed{% endtrans %}"></i></li>
  84. {% endif %}
  85. </ul>
  86. </td>
  87. <td>
  88. <div class="thread-rating{% if (thread.upvotes-thread.downvotes) > 0 %} thread-rating-positive{% elif (thread.upvotes-thread.downvotes) < 0 %} thread-rating-negative{% endif %}">
  89. {% if (thread.upvotes-thread.downvotes) > 0 %}+{% elif (thread.upvotes-thread.downvotes) < 0 %}-{% endif %}{{ (thread.upvotes-thread.downvotes)|abs|intcomma }}
  90. </div>
  91. </td>
  92. <td>
  93. <div class="thread-last-reply">
  94. {{ replies(thread.replies) }} - {% trans user=thread_reply(thread), last=thread.last|reltimesince|low %}last by {{ user }} {{ last }}{% endtrans %}
  95. </div>
  96. </td>
  97. {% if list_form %}
  98. <td class="check-cell">{% if thread.forum_id == forum.pk %}<label class="checkbox"><input form="threads_form" name="{{ list_form['list_items']['html_name'] }}" type="checkbox" class="checkbox-member" value="{{ thread.pk }}"{% if list_form['list_items']['has_value'] and ('' ~ thread.pk) in list_form['list_items']['value'] %} checked="checked"{% endif %}></label>{% else %}&nbsp;{% endif %}</td>
  99. {% endif %}
  100. </tr>
  101. {% else %}
  102. <tr>
  103. <td colspan="4" class="threads-list-empty">
  104. {% if tab == 'all' %}
  105. {% trans %}You are not participating in any private discussions.{% endtrans %}
  106. {% elif tab == 'new' %}
  107. {% trans %}There are no unread private threads.{% endtrans %}
  108. {% else %}
  109. {% trans %}You have started no private threads.{% endtrans %}
  110. {% endif %}
  111. </td>
  112. </tr>
  113. {% endfor %}
  114. </tbody>
  115. </table>
  116. {% if list_form %}
  117. <div class="threads-actions">
  118. <form id="threads_form" class="form-inline pull-right" action="{{ route_name()|url() }}" method="POST">
  119. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  120. {{ form_theme.input_select(list_form['list_action'],width=3) }}
  121. <button type="submit" class="btn btn-danger">{% trans %}Go{% endtrans %}</button>
  122. </form>
  123. </div>
  124. {% endif %}
  125. </div>
  126. <div class="forum-threads-extra">
  127. {{ pager() }}
  128. {% if acl.threads.can_start_threads(forum) %}
  129. <a href="{% url 'private_thread_start' %}" class="btn btn-inverse pull-right"><i class="icon-plus"></i> {% trans %}New Thread{% endtrans %}</a>
  130. {% endif %}
  131. </div>
  132. </div>
  133. {% endblock %}
  134. {% macro route_name() -%}
  135. {% filter trim %}
  136. {% if tab == 'all' %}
  137. private_threads
  138. {% elif tab == 'new' %}
  139. new_private_threads
  140. {% else %}
  141. my_private_threads
  142. {% endif %}
  143. {% endfilter %}
  144. {%- endmacro %}
  145. {% macro replies(thread_replies) -%}
  146. {% trans count=thread_replies, replies=('<strong>' ~ (thread_replies|intcomma) ~ '</strong>')|safe -%}
  147. {{ replies }} reply
  148. {%- pluralize -%}
  149. {{ replies }} replies
  150. {%- endtrans %}
  151. {%- endmacro %}
  152. {% macro thread_starter(thread) -%}
  153. {% if thread.start_poster_id %}<a href="{% url 'user' user=thread.start_poster_id, username=thread.start_poster_slug %}" class="user-link">{{ thread.start_poster_name }}</a>{% else %}{{ thread.start_poster_name }}{% endif %}
  154. {%- endmacro %}
  155. {% macro thread_reply(thread) -%}
  156. {% if thread.last_poster_id %}<a href="{% url 'user' user=thread.last_poster_id, username=thread.last_poster_slug %}" class="user-link">{{ thread.last_poster_name }}</a>{% else %}{{ thread.last_poster_name }}{% endif %}
  157. {%- endmacro %}
  158. {% macro pager() %}
  159. {% if pagination['total'] > 0 %}
  160. <div class="pagination pull-left">
  161. <ul>
  162. <li class="count">{{ macros.pager_label(pagination) }}</li>
  163. {%- if pagination['prev'] > 1 %}<li><a href="{{ route_name()|url }}" class="tooltip-top" title="{% trans %}First Page{% endtrans %}"><i class="icon-chevron-left"></i> {% trans %}First{% endtrans %}</a></li>{% endif -%}
  164. {%- if pagination['prev'] > 0 %}<li><a href="{%- if pagination['prev'] > 1 %}{{ route_name()|url(page=pagination['prev']) }}{% else %}{{ route_name()|url() }}{% endif %}" class="tooltip-top" title="{% trans %}Newest Threads{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
  165. {%- if pagination['next'] > 0 %}<li><a href="{{ route_name()|url(page=pagination['next']) }}" class="tooltip-top" title="{% trans %}Older Threads{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  166. </ul>
  167. </div>
  168. {% endif %}
  169. {% endmacro %}
  170. {% block javascripts -%}
  171. {{ super() }}
  172. {%- if list_form %}
  173. <script type="text/javascript">
  174. $(function () {
  175. $('#threads_form').submit(function() {
  176. if ($('.check-cell[]:checked').length == 0) {
  177. alert("{% trans %}You have to select at least one thread.{% endtrans %}");
  178. return false;
  179. }
  180. if ($('#id_list_action').val() == 'hard') {
  181. var decision = confirm("{% trans %}Are you sure you want to delete selected threads? This action is not reversible!{% endtrans %}");
  182. return decision;
  183. }
  184. return true;
  185. });
  186. });
  187. </script>{% endif %}
  188. {%- endblock %}