made voting threshold configurable

This commit is contained in:
James Tauber 2012-08-14 15:52:23 -04:00
parent 2789537cb4
commit 0aca96152f
3 changed files with 36 additions and 23 deletions

8
symposion/conf.py Normal file
View file

@ -0,0 +1,8 @@
from django.conf import settings
from appconf import AppConf
class SymposionAppConf(AppConf):
VOTE_THRESHOLD = 3

View file

@ -4,12 +4,14 @@ from django.views.decorators.http import require_POST
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from symposion.conf import settings
from symposion.proposals.models import ProposalBase, ProposalSection from symposion.proposals.models import ProposalBase, ProposalSection
from symposion.teams.models import Team
from symposion.utils.mail import send_email
from symposion.reviews.forms import ReviewForm, SpeakerCommentForm from symposion.reviews.forms import ReviewForm, SpeakerCommentForm
from symposion.reviews.forms import BulkPresentationForm from symposion.reviews.forms import BulkPresentationForm
from symposion.reviews.models import ReviewAssignment, Review, LatestVote, ProposalResult from symposion.reviews.models import ReviewAssignment, Review, LatestVote, ProposalResult
from symposion.teams.models import Team
from symposion.utils.mail import send_email
def access_not_permitted(request): def access_not_permitted(request):
@ -272,8 +274,11 @@ def review_delete(request, pk):
@login_required @login_required
def review_status(request, section_slug=None, key=None): def review_status(request, section_slug=None, key=None):
VOTE_THRESHOLD = settings.SYMPOSION_VOTE_THRESHOLD
ctx = { ctx = {
"section_slug": section_slug "section_slug": section_slug,
"vote_threshold": VOTE_THRESHOLD,
} }
queryset = ProposalBase.objects.select_related("speaker__user", "result").select_subclasses() queryset = ProposalBase.objects.select_related("speaker__user", "result").select_subclasses()
@ -281,16 +286,16 @@ def review_status(request, section_slug=None, key=None):
queryset = queryset.filter(kind__section__slug=section_slug) queryset = queryset.filter(kind__section__slug=section_slug)
proposals = { proposals = {
# proposals with at least 3 reviews and at least one +1 and no -1s, sorted by the 'score' # proposals with at least VOTE_THRESHOLD reviews and at least one +1 and no -1s, sorted by the 'score'
"positive": queryset.filter(result__vote_count__gte=3, result__plus_one__gt=0, result__minus_one=0).order_by("-result__score"), "positive": queryset.filter(result__vote_count__gte=VOTE_THRESHOLD, result__plus_one__gt=0, result__minus_one=0).order_by("-result__score"),
# proposals with at least 3 reviews and at least one -1 and no +1s, reverse sorted by the 'score' # proposals with at least VOTE_THRESHOLD reviews and at least one -1 and no +1s, reverse sorted by the 'score'
"negative": queryset.filter(result__vote_count__gte=3, result__minus_one__gt=0, result__plus_one=0).order_by("result__score"), "negative": queryset.filter(result__vote_count__gte=VOTE_THRESHOLD, result__minus_one__gt=0, result__plus_one=0).order_by("result__score"),
# proposals with at least 3 reviews and neither a +1 or a -1, sorted by total votes (lowest first) # proposals with at least VOTE_THRESHOLD reviews and neither a +1 or a -1, sorted by total votes (lowest first)
"indifferent": queryset.filter(result__vote_count__gte=3, result__minus_one=0, result__plus_one=0).order_by("result__vote_count"), "indifferent": queryset.filter(result__vote_count__gte=VOTE_THRESHOLD, result__minus_one=0, result__plus_one=0).order_by("result__vote_count"),
# proposals with at least 3 reviews and both a +1 and -1, sorted by total votes (highest first) # proposals with at least VOTE_THRESHOLD reviews and both a +1 and -1, sorted by total votes (highest first)
"controversial": queryset.filter(result__vote_count__gte=3, result__plus_one__gt=0, result__minus_one__gt=0).order_by("-result__vote_count"), "controversial": queryset.filter(result__vote_count__gte=VOTE_THRESHOLD, result__plus_one__gt=0, result__minus_one__gt=0).order_by("-result__vote_count"),
# proposals with fewer than 3 reviews # proposals with fewer than VOTE_THRESHOLD reviews
"too_few": queryset.filter(result__vote_count__lt=3).order_by("result__vote_count"), "too_few": queryset.filter(result__vote_count__lt=VOTE_THRESHOLD).order_by("result__vote_count"),
} }
admin = request.user.has_perm("reviews.can_manage_%s" % section_slug) admin = request.user.has_perm("reviews.can_manage_%s" % section_slug)

View file

@ -15,23 +15,23 @@
<div> <div>
{% if key == "positive" %} {% if key == "positive" %}
<h3>Positive <h3>Positive
<small>proposals with at least 3 votes and at least one +1 and no &minus;1s</small></h3> <small>proposals with at least {{ vote_threshold }} vote{{ vote_threshold|pluralize }} and at least one +1 and no &minus;1s</small></h3>
{% endif %} {% endif %}
{% if key == "negative" %} {% if key == "negative" %}
<h3>Negative <h3>Negative
<small>proposals with at least 3 votes and at least one &minus;1 and no +1s</small></h3> <small>proposals with at least {{ vote_threshold }} vote{{ vote_threshold|pluralize }} and at least one &minus;1 and no +1s</small></h3>
{% endif %} {% endif %}
{% if key == "indifferent" %} {% if key == "indifferent" %}
<h3>Indifferent <h3>Indifferent
<small>proposals with at least 3 votes and neither a +1 or a &minus;1</small></h3> <small>proposals with at least {{ vote_threshold }} vote{{ vote_threshold|pluralize }} and neither a +1 or a &minus;1</small></h3>
{% endif %} {% endif %}
{% if key == "controversial" %} {% if key == "controversial" %}
<h3>Controversial <h3>Controversial
<small>proposals with at least 3 votes and both a +1 and &minus;1</small></h3> <small>proposals with at least {{ vote_threshold }} vote{{ vote_threshold|pluralize }} and both a +1 and &minus;1</small></h3>
{% endif %} {% endif %}
{% if key == "too_few" %} {% if key == "too_few" %}
<h3>Too Few Reviews <h3>Too Few Reviews
<small>proposals with fewer than 3 votes</small></h3> <small>proposals with fewer than {{ vote_threshold }} vote{{ vote_threshold|pluralize }}</small></h3>
{% endif %} {% endif %}
{% include "reviews/_review_table.html" %} {% include "reviews/_review_table.html" %}
@ -46,35 +46,35 @@
<span class="badge">{{ proposals.positive.count }}</span> <span class="badge">{{ proposals.positive.count }}</span>
</dt> </dt>
<dd> <dd>
proposals with at least 3 votes and at least one +1 and no &minus;1s proposals with at least {{ vote_threshold }} vote{{ vote_threshold|pluralize }} and at least one +1 and no &minus;1s
</dd> </dd>
<dt> <dt>
<a href="{% url review_status section_slug "negative" %}">Negative</a> <a href="{% url review_status section_slug "negative" %}">Negative</a>
<span class="badge">{{ proposals.negative.count }}</span> <span class="badge">{{ proposals.negative.count }}</span>
</dt> </dt>
<dd> <dd>
proposals with at least 3 votes and at least one &minus;1 and no +1s proposals with at least {{ vote_threshold }} vote{{ vote_threshold|pluralize }} and at least one &minus;1 and no +1s
</dd> </dd>
<dt> <dt>
<a href="{% url review_status section_slug "indifferent" %}">Indifferent</a> <a href="{% url review_status section_slug "indifferent" %}">Indifferent</a>
<span class="badge">{{ proposals.indifferent.count }}</span> <span class="badge">{{ proposals.indifferent.count }}</span>
</dt> </dt>
<dd> <dd>
proposals with at least 3 votes and neither a +1 or a &minus;1 proposals with at least {{ vote_threshold }} vote{{ vote_threshold|pluralize }} and neither a +1 or a &minus;1
</dd> </dd>
<dt> <dt>
<a href="{% url review_status section_slug "controversial" %}">Controversial</a> <a href="{% url review_status section_slug "controversial" %}">Controversial</a>
<span class="badge">{{ proposals.controversial.count }}</span> <span class="badge">{{ proposals.controversial.count }}</span>
</dt> </dt>
<dd> <dd>
proposals with at least 3 votes and both a +1 and &minus;1 proposals with at least {{ vote_threshold }} vote{{ vote_threshold|pluralize }} and both a +1 and &minus;1
</dd> </dd>
<dt> <dt>
<a href="{% url review_status section_slug "too_few" %}">Too Few Reviews</a> <a href="{% url review_status section_slug "too_few" %}">Too Few Reviews</a>
<span class="badge">{{ proposals.too_few.count }}</span> <span class="badge">{{ proposals.too_few.count }}</span>
</dt> </dt>
<dd> <dd>
proposals with fewer than 3 votes proposals with fewer than {{ vote_threshold }} vote{{ vote_threshold|pluralize }}
</dd> </dd>
</dl> </dl>
{% endif %} {% endif %}