Show invalid votes and votes cast for application and assignment results.
This commit is contained in:
parent
a9fd09951b
commit
cc10d5042b
@ -29,9 +29,12 @@
|
||||
<p><nobr><label>{%trans "Abstentions" %}:</label></nobr>
|
||||
{{ options.0.form.undesided.errors }}{{ options.0.form.undesided }}
|
||||
</p>
|
||||
<p><label>{%trans "Invalid" %}:</label>
|
||||
<p><label>{%trans "Invalid votes" %}:</label>
|
||||
{{ form.invalid.errors }}{{ form.invalid }}
|
||||
</p>
|
||||
<p><label>{%trans "Votes cast" %}:</label>
|
||||
{{ form.votescast.errors }}{{ form.votescast }}
|
||||
</p>
|
||||
<p>
|
||||
<button type="submit">
|
||||
<span class="icon ok">{%trans 'Apply' %}</span>
|
||||
|
@ -70,15 +70,17 @@
|
||||
<br>
|
||||
{% if poll.has_vote %}
|
||||
{% for option in poll.options %}
|
||||
{% trans "Yes" %}: {{ option.yes }}<br>
|
||||
{% trans "No" %}: {{ option.no }}<br>
|
||||
{% trans "Abstention" %}: {{ option.undesided }}<br>
|
||||
{% trans "Invalid" %}: {{ poll.votesinvalid }}
|
||||
<img src="/static/images/icons/voting-yes.png" title="{% trans 'Yes' %}"> {{ option.yes }}<br>
|
||||
<img src="/static/images/icons/voting-no.png" title="{% trans 'No' %}"> {{ option.no }}<br>
|
||||
<img src="/static/images/icons/voting-abstention.png" title="{% trans 'Abstention' %}"> {{ option.undesided }}<br>
|
||||
<img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ poll.votesinvalid }}<br>
|
||||
<div style="border-top: 1px solid; padding-top: 5px; margin: 5px 0; width: 5em;">
|
||||
<img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> {{ poll.votescast }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if perms.application.can_manage_application %}
|
||||
{% if forloop.last %}
|
||||
{% if "genpoll" in actions %}
|
||||
<br>
|
||||
<a href='{% url application_gen_poll application.id %}'>
|
||||
<button><span class="icon poll">{%trans 'New vote' %}</span></button>
|
||||
</a>
|
||||
|
@ -20,7 +20,7 @@ from openslides.application.models import Application
|
||||
from openslides.application.forms import ApplicationForm, \
|
||||
ApplicationManagerForm
|
||||
from openslides.poll.models import Poll
|
||||
from openslides.poll.forms import OptionResultForm, PollInvalidForm
|
||||
from openslides.poll.forms import OptionResultForm, PollForm
|
||||
from openslides.utils.utils import template, permission_required, \
|
||||
render_to_forbitten, del_confirm_form
|
||||
from openslides.utils.pdf import print_application, print_application_poll
|
||||
@ -322,9 +322,10 @@ def view_poll(request, poll_id):
|
||||
options = poll.options
|
||||
if request.user.has_perm('application.can_manage_applications'):
|
||||
if request.method == 'POST':
|
||||
form = PollInvalidForm(request.POST, prefix="poll")
|
||||
form = PollForm(request.POST, prefix="poll")
|
||||
if form.is_valid():
|
||||
poll.votesinvalid = form.cleaned_data['invalid'] or 0
|
||||
poll.votescast = form.cleaned_data['votescast'] or 0
|
||||
poll.save()
|
||||
|
||||
for option in options:
|
||||
@ -337,7 +338,7 @@ def view_poll(request, poll_id):
|
||||
cleaned_data['undesided'] or 0
|
||||
option.save()
|
||||
else:
|
||||
form = PollInvalidForm(initial={'invalid': poll.votesinvalid}, prefix="poll")
|
||||
form = PollForm(initial={'invalid': poll.votesinvalid, 'votescast': poll.votescast}, prefix="poll")
|
||||
for option in options:
|
||||
option.form = OptionResultForm(initial={
|
||||
'yes': option.voteyes,
|
||||
|
@ -33,9 +33,12 @@
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<label for="id_votesinvalid">{% trans "Invalid" %}:</label>
|
||||
<label for="id_votesinvalid">{% trans "Invalid votes" %}:</label>
|
||||
{{ form.invalid.errors }}{{ form.invalid }}
|
||||
|
||||
<label for="id_votescast">{% trans "Votes cast" %}:</label>
|
||||
{{ form.votescast.errors }}{{ form.votescast }}
|
||||
|
||||
{% if perms.poll.can_manage_poll %}
|
||||
<p>
|
||||
<button type="submit">
|
||||
|
@ -170,6 +170,24 @@
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td>{%trans 'Invalid votes' %}</td>
|
||||
{% for p in polls %}
|
||||
<td><img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalid }}</td>
|
||||
{% endfor %}
|
||||
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
|
||||
<td></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr class="total">
|
||||
<td><b>{%trans 'Votes cast' %}</b></td>
|
||||
{% for p in polls %}
|
||||
<td><img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> <b>{{ p.votescast }}</b></td>
|
||||
{% endfor %}
|
||||
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
|
||||
<td></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{% else %}
|
||||
|
@ -17,7 +17,7 @@ from django.contrib.auth.decorators import login_required
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from poll.models import Poll, Option
|
||||
from poll.forms import OptionResultForm, PollInvalidForm
|
||||
from poll.forms import OptionResultForm, PollForm
|
||||
from assignment.models import Assignment
|
||||
from assignment.forms import AssignmentForm, AssignmentRunForm
|
||||
from utils.utils import template, permission_required, gen_confirm_form, del_confirm_form, ajax_request
|
||||
@ -79,9 +79,14 @@ def view(request, assignment_id=None):
|
||||
tmplist[1].append("-")
|
||||
votes.append(tmplist)
|
||||
|
||||
polls = []
|
||||
for poll in assignment.poll_set.filter(assignment=assignment):
|
||||
polls.append(poll)
|
||||
|
||||
return {'assignment': assignment,
|
||||
'form': form,
|
||||
'votes': votes}
|
||||
'votes': votes,
|
||||
'polls': polls }
|
||||
|
||||
|
||||
@permission_required('assignment.can_manage_assignment')
|
||||
@ -192,9 +197,10 @@ def poll_view(request, poll_id):
|
||||
assignment = poll.assignment
|
||||
if request.user.has_perm('assignment.can_manage_assignment'):
|
||||
if request.method == 'POST':
|
||||
form = PollInvalidForm(request.POST, prefix="poll")
|
||||
form = PollForm(request.POST, prefix="poll")
|
||||
if form.is_valid():
|
||||
poll.votesinvalid = form.cleaned_data['invalid'] or 0
|
||||
poll.votescast = form.cleaned_data['votescast'] or 0
|
||||
poll.save()
|
||||
|
||||
success = 0
|
||||
@ -209,7 +215,7 @@ def poll_view(request, poll_id):
|
||||
if success == options.count():
|
||||
messages.success(request, _("Votes are successfully saved.") )
|
||||
else:
|
||||
form = PollInvalidForm(initial={'invalid': poll.votesinvalid}, prefix="poll")
|
||||
form = PollForm(initial={'invalid': poll.votesinvalid, 'votescast': poll.votescast}, prefix="poll")
|
||||
for option in options:
|
||||
option.form = OptionResultForm(initial={
|
||||
'yes': option.voteyes,
|
||||
|
@ -20,19 +20,12 @@ class PollForm(ModelForm):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
|
||||
#votescast = IntegerField(required=False,widget=TextInput(attrs={'class':'small-input'}),label=_("Votes cast"))
|
||||
#invalid = IntegerField(required=False, min_value=0, widget=TextInput(attrs={'class': 'small-input'}), label=_("Invalid"))
|
||||
votescast = IntegerField(required=False,widget=TextInput(attrs={'class':'small-input'}),label=_("Votes cast"))
|
||||
invalid = IntegerField(required=False, min_value=0, widget=TextInput(attrs={'class': 'small-input'}), label=_("Invalid"))
|
||||
|
||||
class Meta:
|
||||
model = Poll
|
||||
|
||||
class PollInvalidForm(Form):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
|
||||
invalid = IntegerField(required=False, min_value=0, widget=TextInput(attrs={'class': 'small-input'}), label=_("Invalid"))
|
||||
|
||||
|
||||
class OptionForm(ModelForm):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
|
BIN
openslides/static/images/icons/voting-total.png
Normal file
BIN
openslides/static/images/icons/voting-total.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 912 B |
@ -248,6 +248,10 @@ table a.table_edit {
|
||||
padding: 5px 0;
|
||||
font-size:11px;
|
||||
margin:0;
|
||||
width: 0;
|
||||
}
|
||||
tr.total td {
|
||||
border-top: 1px solid #333333;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user