Skip to content
This repository was archived by the owner on May 19, 2021. It is now read-only.

Commit a07fefe

Browse files
committed
WIP: topic polls
1 parent fabce09 commit a07fefe

File tree

4 files changed

+265
-0
lines changed

4 files changed

+265
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{#
2+
forum/revisions.html
3+
~~~~~~~~~~~~~~~~~~~~
4+
5+
This page shows all old revisions of a post and gives the moderator the
6+
possibility to restore it.
7+
8+
:copyright: (c) 2013-2016 by the Inyoka Team, see AUTHORS for more details.
9+
:license: BSD, see LICENSE for more details.
10+
#}
11+
{% extends 'forum/base.html' %}
12+
13+
{% block title %}
14+
{{ post.topic.title }} – {% trans %}Old revisions{% endtrans %}
15+
– {{ super() }}
16+
{% endblock %}
17+
18+
{% block breadcrumb %}
19+
{{ super() }}
20+
21+
{{ macros.breadcrumb_item(post.topic.title, post.topic|url) }}
22+
{{ macros.breadcrumb_item(_('Old revisions'), post|url('revisions')) }}
23+
{% endblock %}
24+
25+
26+
{% block content %}
27+
{% for rev in revisions %}
28+
<div class="forum-post {% if rev.post.hidden %}forum-post-muted{% endif %}">
29+
<div class="forum-post-heading">
30+
<a href="{{ post|url }}">
31+
<time datetime="{{ rev.store_date|datetime('c') }}">
32+
{{ rev.store_date|datetime }}
33+
</time>
34+
35+
{% if loop.first %}
36+
{% trans %}(Current revision){% endtrans %}
37+
{% endif %}
38+
</a>
39+
</div>
40+
41+
<div class="forum-post-body">
42+
{{ rev.text_rendered }}
43+
</div>
44+
45+
<div class="forum-post-footer">
46+
<div class="button-group">
47+
<a href="{{ rev|url('restore') }}" class="btn btn-default">
48+
{% trans %}Restore{% endtrans %}
49+
</a>
50+
</div>
51+
</div>
52+
</div>
53+
{% endfor %}
54+
55+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{#
2+
forum/splittopic.html
3+
~~~~~~~~~~~~~~~~~~~~~
4+
5+
This page shows the "splittopic" form.
6+
7+
:copyright: (c) 2013-2016 by the Inyoka Team, see AUTHORS for more details.
8+
:license: BSD, see LICENSE for more details.
9+
#}
10+
{% extends 'forum/base.html' %}
11+
12+
{% block title %}
13+
{# TODO #}
14+
{% endblock %}
15+
16+
{% block breadcrumb %}
17+
{{ super() }}
18+
19+
{{ macros.breadcrumb_item(_('Split topic'), topic|url('split')) }}
20+
{{ macros.breadcrumb_item(topic.title, topic|url) }}
21+
{{ macros.breadcrumb_item(topic.forum.name, topic.forum|url) }}
22+
{% endblock %}
23+
24+
{% block content %}
25+
{{ macros.outer_form(csrf_token(), form) }}
26+
27+
{#
28+
<form action="" method="post" class="new_topic">
29+
{{ csrf_token() }}
30+
<h2>{% trans topic=topic.title|e %}Split topic “{{ topic }}”{% endtrans %}</h2>
31+
<p>
32+
{% trans %}The chosen posts can form a new topic or be attached to an existing topic.{% endtrans %}
33+
</p>
34+
<dl>
35+
<dt>
36+
<input type="radio" name="action" value="new" id="id_new"{% if form.data.action == 'new' %} checked="checked"{% endif %} />
37+
<label for="id_new">{% trans %}Create new topic{% endtrans %}</label>
38+
</dt>
39+
<dd>
40+
{% trans %}Forum of the new topic:{% endtrans %} {{ form.forum }}{{ form.errors.forum }}
41+
</dd>
42+
<dd>
43+
{% trans %}Title of the new topic:{% endtrans %} {{ form.title }}{{ form.errors.title }}
44+
</dd>
45+
<dd>
46+
Version des neuen Topics:
47+
{{ form.ubuntu_distro }}{{ form.errors.ubuntu_distro }}
48+
{{ form.ubuntu_version }}{{ form.errors.ubuntu_version }}
49+
</dd>
50+
<dt>
51+
<input type="radio" name="action" value="add" id="id_add"{% if form.data.action == 'add' %} checked="checked" {% endif %} />
52+
<label for="id_add">{% trans %}Attach to old topic{% endtrans %}</label>
53+
</dt>
54+
<dd>
55+
{% trans %}Slug of the topic:{% endtrans %} {{ form.topic }}{{ form.errors.topic }}
56+
</dd>
57+
</dl>
58+
59+
<h3>{% trans %}Preview{% endtrans %}</h3>
60+
<p>{% trans %}The following posts will be split off:{% endtrans %}</p>
61+
62+
<table class="topic admin_link_hover">
63+
<tbody>
64+
{%- for post in posts %}
65+
<tr id="post-{{ post.id }}"{% if post.hidden %} class="hidden"{% endif %}>
66+
<td class="author"{%- if post.author_id == USER.id %} style="background-color: #F6F4EF"{%- endif %}>
67+
<p class="username{% if not post.author.is_active %} inactive{% endif %}">
68+
<a href="{{ post.author|url }}">{{ post.author.username|e }}</a>
69+
{%- if post.author.primary_group and post.author.primary_group.icon %}
70+
<img class="teamicon" src="{{ post.author.primary_group.icon_url }}" alt="Teamicon" />
71+
{%- endif %}
72+
</p>
73+
{%- if post.author.member_title %}
74+
<div class="member_title">{{ post.author.member_title|e }}</div>
75+
{%- endif %}
76+
{%- if post.author == topic.author and not loop.first %}
77+
<div class="member_title">{% trans %}(Topic starter){% endtrans %}</div>
78+
{%- endif %}
79+
{%- if post.author.has_avatar and not USER.settings['hide_avatars'] %}
80+
{{ macros.add_user_avatar(post.author) }}
81+
{%- endif %}
82+
<p>{% trans %}Member since:{% endtrans %}<br />{{ post.author.date_joined|naturalday }}</p>
83+
<p>{% trans %}Posts:{% endtrans %} {{ post.author.post_count }}</p>
84+
</td>
85+
<td class="post"{%- if post.author_id == USER.id %} style="background-color: #F8F6F1"{% endif %}>
86+
<div class="postinfo">
87+
<div class="linklist">
88+
</div>
89+
<a href="{{ post|url }}" title="{% trans %}Link to this post{% endtrans %}">{#
90+
#}<img src="{{ href('static', 'img', 'icon_minipost.gif') }}" alt="{% trans %}Post{% endtrans %}" />{#
91+
#}</a>
92+
{{ post.pub_date|datetime }}
93+
</div>
94+
<div class="text">
95+
{{ post.get_text() }}
96+
</div>
97+
{%- set attachments = post.grouped_attachments %}
98+
{%- if attachments %}
99+
<hr />
100+
<dl class="attachments">
101+
{%- for group, list, class in attachments %}
102+
{%- if group %}
103+
<dt>{{ group }}</dt>
104+
<ul class="attr_list{% if class %} {{ class }}{% endif %}">
105+
{%- for att in list %}
106+
<li>{{ att.html_representation }}</li>
107+
{%- endfor %}
108+
</ul>
109+
{%- else %}
110+
{%- for att in list %}
111+
<dt>{{ att.name|e }} ({{ att.size|filesizeformat(true) }})</dt>
112+
{%- if att.comment %}
113+
<dd class="comment">{{ att.comment|e }}</dd>
114+
{%- endif %}
115+
<dd>{{ att.html_representation }}</dd>
116+
{%- endfor %}
117+
{%- endif %}
118+
{%- endfor %}
119+
</dl>
120+
{%- endif %}
121+
{%- if post.author.signature and not USER.settings['hide_signatures'] %}
122+
<div class="signature">
123+
{{ post.author.signature_rendered }}
124+
</div>
125+
{%- endif %}
126+
</td>
127+
</tr>
128+
{%- endfor %}
129+
</tbody>
130+
</table>
131+
<input type="submit" name="split" value="{% trans %}Split posts{% endtrans %}" />
132+
</form>
133+
#}
134+
{% endblock %}

inyoka_theme_default/templates/forum/topic.html

+5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ <h1>{{ topic.title|e }}</h1>
105105
{% endif %}
106106

107107
{{ rendered_pagination }}
108+
109+
{% if polls %}
110+
{% include 'forum/topic__polls.html' %}
111+
{% endif %}
112+
108113
{% for post in posts %}
109114
<div class="forum-post {% if post.hidden %}forum-post-muted{% endif %}" id="post-{{ post.id }}">
110115
<div class="forum-post-heading">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{% call macros.outer_form(csrf_token(), manually_rendered=True, button_visible=False) %}
2+
{% for poll in polls %}
3+
<h2> {% trans %}Poll: {% endtrans %}{{ poll.question|e }}</h2>
4+
5+
<table class="poll">
6+
{% for option in poll.options.all() %}
7+
<tr>
8+
<td>
9+
{% if poll.can_vote and can_vote and not show_vote_results %}
10+
<input type="{{ poll.multiple_votes and 'checkbox' or 'radio' }}"
11+
name="poll_{{ poll.id }}" id="option_{{ option.id }}"
12+
value="{{ option.id }}" />
13+
<label for="option_{{ option.id }}">{{ option.name|e }}</label>
14+
{% else %}
15+
{{ option.name|e }}
16+
{% endif %}
17+
</td>
18+
{% if not (poll.can_vote and can_vote) or show_vote_results %}
19+
<td>
20+
<meter min="0" max="100" value="{{ option.percentage }}" title="%">{{ option.percentage }}</meter>
21+
</td>
22+
{% set bc, ac = (option.percentage|string).split('.') %}
23+
<td class="percentage">
24+
{{ bc }}{% if ac|int %}.{{ ac[:2] }}{% endif %}%
25+
</td>
26+
<td class="votes">
27+
[ {{ option.votes }} ]
28+
</td>
29+
{% endif %}
30+
</tr>
31+
{% endfor %}
32+
</table>
33+
34+
<div>
35+
{% if poll.ended %}
36+
{% trans start_date=poll.start_time|datetime, end_date=poll.end_time|datetime %}
37+
The poll was started on {{ start_date }} and it ended on {{ end_date }}.
38+
{% endtrans %}
39+
{% elif poll.end_time %}
40+
{% trans start_date=poll.start_time|datetime, end_date=poll.end_time|datetime %}
41+
The poll was started on {{ start_date }} and it will end on {{ end_date }}.
42+
{% endtrans %}
43+
{% endif %}
44+
</div>
45+
46+
{% trans count=poll.votes %}
47+
{{ count }} vote
48+
{% pluralize %}
49+
{{ count }} votes
50+
{% endtrans %}
51+
52+
{% if poll.multiple_votes %},
53+
{% trans count=poll.votings.count() %}
54+
{{ count }} voter
55+
{% pluralize %}
56+
{{ count }} voters
57+
{% endtrans %}
58+
{% endif %}
59+
{% endfor %}
60+
61+
{% if can_vote and not voted_all %}
62+
<p>
63+
{% if show_vote_results %}
64+
<a href="?">{% trans %}Hide results{% endtrans %}</a>
65+
{% else %}
66+
<input type="submit" name="vote" value="{% trans %}Vote{% endtrans %}" />
67+
<a href="?action=vote_results">{% trans %}Show results{% endtrans %}</a>
68+
{% endif %}
69+
</p>
70+
{% endif %}
71+
{% endcall %}

0 commit comments

Comments
 (0)