Automated merge with ssh://oshahn.de/openslides

This commit is contained in:
Oskar Hahn 2011-09-03 15:08:26 +02:00
commit 28785c0ed4
9 changed files with 54 additions and 24 deletions

View File

@ -29,9 +29,12 @@
<p><nobr><label>{%trans "Abstentions" %}:</label></nobr> <p><nobr><label>{%trans "Abstentions" %}:</label></nobr>
{{ options.0.form.undesided.errors }}{{ options.0.form.undesided }} {{ options.0.form.undesided.errors }}{{ options.0.form.undesided }}
</p> </p>
<p><label>{%trans "Invalid" %}:</label> <p><label>{%trans "Invalid votes" %}:</label>
{{ form.invalid.errors }}{{ form.invalid }} {{ form.invalid.errors }}{{ form.invalid }}
</p> </p>
<p><label>{%trans "Votes cast" %}:</label>
{{ form.votescast.errors }}{{ form.votescast }}
</p>
<p> <p>
<button type="submit"> <button type="submit">
<span class="icon ok">{%trans 'Apply' %}</span> <span class="icon ok">{%trans 'Apply' %}</span>

View File

@ -70,15 +70,17 @@
<br> <br>
{% if poll.has_vote %} {% if poll.has_vote %}
{% for option in poll.options %} {% for option in poll.options %}
{% trans "Yes" %}: {{ option.yes }}<br> <img src="/static/images/icons/voting-yes.png" title="{% trans 'Yes' %}"> {{ option.yes }}<br>
{% trans "No" %}: {{ option.no }}<br> <img src="/static/images/icons/voting-no.png" title="{% trans 'No' %}"> {{ option.no }}<br>
{% trans "Abstention" %}: {{ option.undesided }}<br> <img src="/static/images/icons/voting-abstention.png" title="{% trans 'Abstention' %}"> {{ option.undesided }}<br>
{% trans "Invalid" %}: {{ poll.votesinvalid }} <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 %} {% endfor %}
{% if perms.application.can_manage_application %} {% if perms.application.can_manage_application %}
{% if forloop.last %} {% if forloop.last %}
{% if "genpoll" in actions %} {% if "genpoll" in actions %}
<br>
<a href='{% url application_gen_poll application.id %}'> <a href='{% url application_gen_poll application.id %}'>
<button><span class="icon poll">{%trans 'New vote' %}</span></button> <button><span class="icon poll">{%trans 'New vote' %}</span></button>
</a> </a>

View File

@ -20,7 +20,7 @@ from openslides.application.models import Application
from openslides.application.forms import ApplicationForm, \ from openslides.application.forms import ApplicationForm, \
ApplicationManagerForm ApplicationManagerForm
from openslides.poll.models import Poll 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, \ from openslides.utils.utils import template, permission_required, \
render_to_forbitten, del_confirm_form render_to_forbitten, del_confirm_form
from openslides.utils.pdf import print_application, print_application_poll from openslides.utils.pdf import print_application, print_application_poll
@ -322,9 +322,10 @@ def view_poll(request, poll_id):
options = poll.options options = poll.options
if request.user.has_perm('application.can_manage_applications'): if request.user.has_perm('application.can_manage_applications'):
if request.method == 'POST': if request.method == 'POST':
form = PollInvalidForm(request.POST, prefix="poll") form = PollForm(request.POST, prefix="poll")
if form.is_valid(): if form.is_valid():
poll.votesinvalid = form.cleaned_data['invalid'] or 0 poll.votesinvalid = form.cleaned_data['invalid'] or 0
poll.votescast = form.cleaned_data['votescast'] or 0
poll.save() poll.save()
for option in options: for option in options:
@ -337,7 +338,7 @@ def view_poll(request, poll_id):
cleaned_data['undesided'] or 0 cleaned_data['undesided'] or 0
option.save() option.save()
else: else:
form = PollInvalidForm(initial={'invalid': poll.votesinvalid}, prefix="poll") form = PollForm(initial={'invalid': poll.votesinvalid, 'votescast': poll.votescast}, prefix="poll")
for option in options: for option in options:
option.form = OptionResultForm(initial={ option.form = OptionResultForm(initial={
'yes': option.voteyes, 'yes': option.voteyes,

View File

@ -33,9 +33,12 @@
{% endfor %} {% endfor %}
</table> </table>
<label for="id_votesinvalid">{% trans "Invalid" %}:</label> <label for="id_votesinvalid">{% trans "Invalid votes" %}:</label>
{{ form.invalid.errors }}{{ form.invalid }} {{ form.invalid.errors }}{{ form.invalid }}
<label for="id_votescast">{% trans "Votes cast" %}:</label>
{{ form.votescast.errors }}{{ form.votescast }}
{% if perms.poll.can_manage_poll %} {% if perms.poll.can_manage_poll %}
<p> <p>
<button type="submit"> <button type="submit">

View File

@ -123,7 +123,7 @@
<th>{% trans "Candidates" %}</th> <th>{% trans "Candidates" %}</th>
{% for poll in assignment.poll_set.all %} {% for poll in assignment.poll_set.all %}
<th style="vertical-align: top; white-space:nowrap;">{% if perms.assignment.can_manage_assignment %}<a href="{% url assignment_poll_view poll.id %}">{% endif %} <th style="vertical-align: top; white-space:nowrap;">{% if perms.assignment.can_manage_assignment %}<a href="{% url assignment_poll_view poll.id %}">{% endif %}
{{forloop.counter}}. {{ forloop.counter }}.
{% if perms.assignment.can_manage_assignment %} {% if perms.assignment.can_manage_assignment %}
</a> </a>
<a href="{% url assignment_poll_delete poll.id %}"><img src="/static/images/icons/edit-delete.png" title="{% trans 'Delete Poll' %}"></a> <a href="{% url assignment_poll_delete poll.id %}"><img src="/static/images/icons/edit-delete.png" title="{% trans 'Delete Poll' %}"></a>
@ -170,6 +170,24 @@
{% endif %} {% endif %}
</tr> </tr>
{% endfor %} {% 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> </table>
{% else %} {% else %}

View File

@ -17,7 +17,7 @@ from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from poll.models import Poll, Option 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.models import Assignment
from assignment.forms import AssignmentForm, AssignmentRunForm from assignment.forms import AssignmentForm, AssignmentRunForm
from utils.utils import template, permission_required, gen_confirm_form, del_confirm_form, ajax_request 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("-") tmplist[1].append("-")
votes.append(tmplist) votes.append(tmplist)
polls = []
for poll in assignment.poll_set.filter(assignment=assignment):
polls.append(poll)
return {'assignment': assignment, return {'assignment': assignment,
'form': form, 'form': form,
'votes': votes} 'votes': votes,
'polls': polls }
@permission_required('assignment.can_manage_assignment') @permission_required('assignment.can_manage_assignment')
@ -192,9 +197,10 @@ def poll_view(request, poll_id):
assignment = poll.assignment assignment = poll.assignment
if request.user.has_perm('assignment.can_manage_assignment'): if request.user.has_perm('assignment.can_manage_assignment'):
if request.method == 'POST': if request.method == 'POST':
form = PollInvalidForm(request.POST, prefix="poll") form = PollForm(request.POST, prefix="poll")
if form.is_valid(): if form.is_valid():
poll.votesinvalid = form.cleaned_data['invalid'] or 0 poll.votesinvalid = form.cleaned_data['invalid'] or 0
poll.votescast = form.cleaned_data['votescast'] or 0
poll.save() poll.save()
success = 0 success = 0
@ -209,7 +215,7 @@ def poll_view(request, poll_id):
if success == options.count(): if success == options.count():
messages.success(request, _("Votes are successfully saved.") ) messages.success(request, _("Votes are successfully saved.") )
else: else:
form = PollInvalidForm(initial={'invalid': poll.votesinvalid}, prefix="poll") form = PollForm(initial={'invalid': poll.votesinvalid, 'votescast': poll.votescast}, prefix="poll")
for option in options: for option in options:
option.form = OptionResultForm(initial={ option.form = OptionResultForm(initial={
'yes': option.voteyes, 'yes': option.voteyes,

View File

@ -20,19 +20,12 @@ class PollForm(ModelForm):
error_css_class = 'error' error_css_class = 'error'
required_css_class = 'required' required_css_class = 'required'
#votescast = IntegerField(required=False,widget=TextInput(attrs={'class':'small-input'}),label=_("Votes cast")) 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")) invalid = IntegerField(required=False, min_value=0, widget=TextInput(attrs={'class': 'small-input'}), label=_("Invalid"))
class Meta: class Meta:
model = Poll 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): class OptionForm(ModelForm):
error_css_class = 'error' error_css_class = 'error'
required_css_class = 'required' required_css_class = 'required'

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

View File

@ -248,6 +248,10 @@ table a.table_edit {
padding: 5px 0; padding: 5px 0;
font-size:11px; font-size:11px;
margin:0; margin:0;
width: 0;
}
tr.total td {
border-top: 1px solid #333333;
} }