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:
parent
7fc12e51f9
commit
08a3cf8490
@ -131,11 +131,11 @@
|
|||||||
</a>
|
</a>
|
||||||
{% if poll.published %}
|
{% if poll.published %}
|
||||||
<a href={% url assignment_poll_notpublish poll.id %}><img
|
<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>
|
title="{% trans 'Unpublish results' %}"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href={% url assignment_poll_publish poll.id %}><img
|
<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>
|
title="{% trans 'Publish results' %}"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<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>
|
||||||
@ -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>
|
||||||
|
@ -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
|
||||||
|
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user