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

@ -184,7 +184,7 @@
{% else %}∅{% endif %} {% else %}∅{% endif %}
</td> </td>
{% endfor %} {% 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> <td></td>
{% endif %} {% endif %}
</tr> </tr>
@ -192,18 +192,18 @@
<tr> <tr>
<td>{%trans 'Invalid votes' %}</td> <td>{%trans 'Invalid votes' %}</td>
{% for p in polls %} {% 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 %} {% 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> <td></td>
{% endif %} {% endif %}
</tr> </tr>
<tr class="total"> <tr class="total">
<td><b>{%trans 'Votes cast' %}</b></td> <td><b>{%trans 'Votes cast' %}</b></td>
{% for p in polls %} {% 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 %} {% 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> <td></td>
{% endif %} {% endif %}
</tr> </tr>

View File

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

View File

@ -40,6 +40,22 @@ class Poll(models.Model):
optionc.save() optionc.save()
return optionc 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): def has_vote(self):
for option in self.options: for option in self.options:
if option.voteyes or option.voteno or option.voteundesided: if option.voteyes or option.voteno or option.voteundesided: