talk score is now average notes

This commit is contained in:
Élie Bouttier 2016-09-16 18:12:21 +02:00
parent b3e5d1207f
commit a48553422f
3 changed files with 14 additions and 7 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-14 20:52+0000\n"
"POT-Creation-Date: 2016-09-16 16:10+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -45,7 +45,7 @@ msgstr "Besoin d'un hébergement ?"
msgid "Ok for homestay?"
msgstr "Ok pour un logement chez l'habitant ?"
#: accounts/models.py:62
#: accounts/models.py:62 proposals/templates/proposals/user_details.html:42
msgid "Constraints"
msgstr "Contraintes"
@ -474,8 +474,12 @@ msgid "Vote:"
msgstr "Vote :"
#: proposals/templates/proposals/talk_detail.html:64
msgid "Sum:"
msgstr "Somme :"
msgid "vote"
msgstr "vote"
#: proposals/templates/proposals/talk_detail.html:64
msgid "average:"
msgstr "moyenne :"
#: proposals/templates/proposals/talk_detail.html:66
msgid "Status:"

View File

@ -91,7 +91,10 @@ class Talk(PonyConfModel):
return user == self.proposer or user in self.speakers.all() or self.is_moderable_by(user)
def score(self):
return query_sum(self.vote_set, 'vote')
if self.vote_set.exists():
return query_sum(self.vote_set, 'vote') / len(self.vote_set.all())
else:
return 0
class Meta:
ordering = ('event__id',)

View File

@ -60,8 +60,8 @@
<a class="btn {% if vote.vote == 1 %} active {% endif %}btn-info" href="{% url 'vote' talk=talk.slug score='1' %}">+1</a>
<a class="btn {% if vote.vote == 2 %} active {% endif %}btn-success" href="{% url 'vote' talk=talk.slug score='2' %}">+2</a>
</div>
{% trans "Sum:" %} {{ talk.score }}
<br /><br />
{{ talk.vote_set.all|length }} {% trans "vote" %}{{ talk.vote_set.all|length|pluralize }}, {% trans "average:" %} {{ talk.score }}
<h3>{% trans "Status:" %}</h3>