From 5735c7745e44aa2ec39465175659e54bdf5ce4d6 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Wed, 17 Aug 2016 07:44:28 +1000 Subject: [PATCH] =?UTF-8?q?The=20=E2=80=9Cfree=20for=20all=E2=80=9D=20rand?= =?UTF-8?q?om=20reviews=20should=20now=20direct=20reviewers=20to=20under-r?= =?UTF-8?q?eviewed=20proposals=20more=20generally.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- symposion/reviews/views.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/symposion/reviews/views.py b/symposion/reviews/views.py index c68e0d9e..482ec0a4 100644 --- a/symposion/reviews/views.py +++ b/symposion/reviews/views.py @@ -208,13 +208,21 @@ def review_random_proposal(request, section_slug): controversial_set = REVIEW_STATUS_FILTERS[CONTROVERSIAL](queryset) if len(too_few_set) > 0: - queryset = too_few_set + proposals = too_few_set.all() elif len(controversial_set) > 0: - queryset = controversial_set + proposals = controversial_set.all() + else: + # Select a proposal with less than the median number of total votes + proposals = proposals_generator(request, queryset, check_speaker=False) + proposals = list(proposals) + proposals.sort(key = lambda proposal: proposal.total_votes) + # The first half is the median or less. + # The +1 means we round _up_. + proposals = proposals[:(len(proposals) + 1) / 2] # Realistically, there shouldn't be all that many proposals to choose # from, so this should be cheap. - chosen = random.choice(queryset.all()) + chosen = random.choice(proposals) return redirect("review_detail", pk=chosen.pk) @@ -262,7 +270,7 @@ def review_admin(request, section_slug): user=user, proposal__kind__section__slug=section_slug, ).count() - + user_votes = LatestVote.objects.filter( user=user, proposal__kind__section__slug=section_slug,