list.html 9.2 KB

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