allow undocumented votecast and voteinvalid

the poll-class has two new properties. voteinvalidf and votescastf. They show
undocumented if the value is -2, else the value
This commit is contained in:
Oskar Hahn 2011-09-09 22:23:42 +02:00
parent 7fc12e51f9
commit 08a3cf8490
3 changed files with 25 additions and 9 deletions

View File

@ -131,11 +131,11 @@
</a>
{% if poll.published %}
<a href={% url assignment_poll_notpublish poll.id %}><img
src="/static/images/icons/user-online.png"
src="/static/images/icons/user-online.png"
title="{% trans 'Unpublish results' %}"></a>
{% else %}
<a href={% url assignment_poll_publish poll.id %}><img
src="/static/images/icons/user-offline.png"
src="/static/images/icons/user-offline.png"
title="{% trans 'Publish results' %}"></a>
{% endif %}
<a href="{% url assignment_poll_delete poll.id %}"><img src="/static/images/icons/edit-delete.png" title="{% trans 'Delete Poll' %}"></a>
@ -184,7 +184,7 @@
{% else %}&empty;{% endif %}
</td>
{% endfor %}
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
{% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
</tr>
@ -192,18 +192,18 @@
<tr>
<td>{%trans 'Invalid votes' %}</td>
{% for p in polls %}
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalid }}</td>
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-invalid.png" title="{% trans 'Invalid' %}"> {{ p.votesinvalidf }}</td>
{% endfor %}
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
{% if assignment.profile.exists 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 style="white-space:nowrap;"><img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> <b>{{ p.votescast }}</b></td>
<td style="white-space:nowrap;"><img src="/static/images/icons/voting-total.png" title="{% trans 'Votes cast' %}"> <b>{{ p.votescastf }}</b></td>
{% endfor %}
{% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
{% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
</tr>

View File

@ -20,8 +20,8 @@ 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, min_value=-2, widget=TextInput(attrs={'class':'small-input'}),label=_("Votes cast"))
invalid = IntegerField(required=False, min_value=-2, widget=TextInput(attrs={'class': 'small-input'}), label=_("Invalid"))
class Meta:
model = Poll

View File

@ -40,6 +40,22 @@ class Poll(models.Model):
optionc.save()
return optionc
@property
def votescastf(self):
if self.votescast == -2:
return _('undocumented')
elif self.votescast:
return self.votescast
return '0'
@property
def votesinvalidf(self):
if self.votesinvalid == -2:
return _('undocumented')
elif self.votesinvalid:
return self.votesinvalid
return '0'
def has_vote(self):
for option in self.options:
if option.voteyes or option.voteno or option.voteundesided: