poll_votes.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. {% extends "cranefly/layout.html" %}
  2. {% import "cranefly/macros.html" as macros with context %}
  3. {% block title %}{{ macros.page_title(title=_("Poll Participants"),parent=thread.name) }}{% endblock %}
  4. {% block breadcrumb %}{{ super() }} <span class="divider"><i class="icon-chevron-right"></i></span></li>
  5. {{ macros.parents_list(parents) }}
  6. <li><a href="{{ url('thread', thread=thread.pk, slug=thread.slug) }}">{{ thread.name }}</a> <span class="divider"><i class="icon-chevron-right"></i></span></li>
  7. <li class="active">{% trans %}Poll Participants{% endtrans %}
  8. {%- endblock %}
  9. {% block container %}
  10. <div class="page-header header-primary">
  11. <div class="container">
  12. {{ messages_list(messages) }}
  13. <ul class="breadcrumb">
  14. {{ self.breadcrumb() }}</li>
  15. </ul>
  16. <h1>{{ poll.question }} <small>{{ thread.name|short_string(42) }}</small></h1>
  17. <ul class="unstyled header-stats">
  18. <li><i class="icon-time"></i> {{ poll.start_date|reltimesince }}</a></li>
  19. <li><i class="icon-user"></i> {% if poll.user_id %}<a href="{{ url('user', user=poll.user_id, username=poll.user_slug) }}">{{ poll.user_name }}</a>{% else %}{{ poll.user_name }}{% endif %}</li>
  20. <li><i class="icon-tasks"></i> {% if poll.votes %}{% trans votes=poll.votes %}One vote{% pluralize %}{{ votes }} votes{% endtrans %}{% else %}{% trans %}No votes{% endtrans %}{% endif %}</li>
  21. {% if thread.closed or thread.deleted %}
  22. <li><i class="icon-lock"></i> {% trans %}Poll has been closed.{% endtrans %}</li>
  23. {% elif thread.poll.over %}
  24. <li><i class="icon-calendar"></i> {% trans end=poll.end_date|date %}Poll ended on {{ end }}{% endtrans %}</li>
  25. {% elif thread.poll.length %}
  26. <li><i class="icon-calendar"></i> {% trans end=poll.end_date|date %}Poll ends on {{ end }}{% endtrans %}</li>
  27. {% else %}
  28. <li><i class="icon-lock"></i> {% trans %}Permanent poll.{% endtrans %}</li>
  29. {% endif %}
  30. </ul>
  31. </div>
  32. </div>
  33. <div class="container container-primary">
  34. <div class="poll-votes-list">
  35. {% for option in options %}
  36. <div class="poll-option">
  37. <h2>{{ option.name }} <small>
  38. {% if option.pk in user_votes %}<strong>{% trans %}Your vote{% endtrans %}</strong>{% endif %}
  39. {% trans votes=option.votes, percent=((option.votes * 100 / poll.votes) if poll.votes else 0)|int -%}
  40. {{ votes }} vote, {{ percent }}% of all
  41. {%- pluralize -%}
  42. {{ votes }} votes, {{ percent }}% of all
  43. {%- endtrans %}</small></h2>
  44. {% if option.votes %}
  45. <table class="table table-striped">
  46. <tbody>
  47. {% for row in option.votes_list|batch(4, '') %}
  48. <tr>
  49. {% for vote in row %}
  50. <td class="span3">
  51. {% if vote %}
  52. {{ vote_details(vote) }}
  53. {% else %}
  54. &nbsp;
  55. {% endif %}
  56. </td>
  57. {% endfor %}
  58. </tr>
  59. {% endfor %}
  60. </tbody>
  61. </table>
  62. {% else %}
  63. <p class="lead">{% trans %}Nobody voted for this option.{% endtrans %}</p>
  64. {% endif %}
  65. </div>
  66. {% if not loop.last %}
  67. <hr>
  68. {% endif %}
  69. {% endfor %}
  70. </div>
  71. </div>
  72. {% endblock %}
  73. {% block javascripts %}{{ super() }}
  74. <script type="text/javascript">
  75. $(function() {
  76. {% for option in options %}
  77. {% for vote in option.votes_list %}
  78. $('.vote-{{ vote.id }}').popover({
  79. 'placement': 'top',
  80. 'trigger': 'hover',
  81. 'html': true,
  82. {% if acl.users.can_see_users_trails() %}
  83. 'title': '<strong>{{ vote.date|reldate }}</strong>',
  84. 'content': '{% trans ip=vote.ip %}From {{ ip }}{% endtrans %}'
  85. {% else %}
  86. 'content': '<strong>{{ vote.date|reldate }}</strong>'
  87. {% endif %}
  88. });
  89. {% endfor %}
  90. {% endfor %}
  91. });
  92. </script>
  93. {% endblock %}
  94. {% macro vote_details(vote) %}
  95. {% if vote.user_id %}
  96. <a href="{{ url('user', user=vote.user_id, username=vote.user_slug) }}" class="vote-user vote-{{ vote.pk }}">{{ vote.user_name }}</a>
  97. {% else %}
  98. <span class="vote-user vote-{{ vote.pk }}">{{ vote.user_name }}</span>
  99. {% endif %}
  100. {% endmacro %}