poll_votes.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {% extends "cranefly/layout.html" %}
  2. {% import "cranefly/macros.html" as macros with context %}
  3. {% block title %}{{ macros.page_title(title=_("Poll Votes"),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 Votes{% 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. {% endif %}
  28. </ul>
  29. </div>
  30. </div>
  31. <div class="container container-primary">
  32. <div class="poll-votes-list">
  33. {% for option in options %}
  34. <div class="poll-option">
  35. <h2>{{ option.name }} <small>
  36. {% if option.pk in user_votes %}<strong>{% trans %}Your vote{% endtrans %}</strong>{% endif %}
  37. {% trans votes=option.votes, percent=((option.votes * 100 / poll.votes) if poll.votes else 0)|int -%}
  38. {{ votes }} vote, {{ percent }}% of all
  39. {%- pluralize -%}
  40. {{ votes }} votes, {{ percent }}% of all
  41. {%- endtrans %}</small></h2>
  42. {% if option.votes %}
  43. <table class="table table-striped">
  44. <tbody>
  45. {% for row in option.votes_list|batch(4, '') %}
  46. <tr>
  47. {% for vote in row %}
  48. <td class="span3">
  49. {% if vote %}
  50. {{ vote_details(vote) }}
  51. {% else %}
  52. &nbsp;
  53. {% endif %}
  54. </td>
  55. {% endfor %}
  56. </tr>
  57. {% endfor %}
  58. </tbody>
  59. </table>
  60. {% else %}
  61. <p class="lead">{% trans %}Nobody voted on this option.{% endtrans %}</p>
  62. {% endif %}
  63. </div>
  64. {% if not loop.last %}
  65. <hr>
  66. {% endif %}
  67. {% endfor %}
  68. </div>
  69. </div>
  70. {% endblock %}
  71. {% block javascripts %}{{ super() }}
  72. <script type="text/javascript">
  73. $(function() {
  74. {% for option in options %}
  75. {% for vote in option.votes_list %}
  76. $('.vote-{{ vote.id }}').popover({
  77. 'placement': 'top',
  78. 'trigger': 'hover',
  79. 'html': true,
  80. {% if acl.users.can_see_users_trails() %}
  81. 'title': '<strong>{{ vote.date|reldate }}</strong>',
  82. 'content': '{% trans ip=vote.ip %}From {{ ip }}{% endtrans %}'
  83. {% else %}
  84. 'content': '<strong>{{ vote.ip }}</strong>'
  85. {% endif %}
  86. });
  87. {% endfor %}
  88. {% endfor %}
  89. });
  90. </script>
  91. {% endblock %}
  92. {% macro vote_details(vote) %}
  93. {% if vote.user_id %}
  94. <a href="{{ url('user', user=vote.user_id, username=vote.user_slug) }}" class="vote-user vote-{{ vote.pk }}">{{ vote.user_name }}</a>
  95. {% else %}
  96. <span class="vote-user vote-{{ vote.pk }}">{{ vote.user_name }}</span>
  97. {% endif %}
  98. {% endmacro %}