Return an integer for the slice index.

Resolves:

    File "/app/symposion_app/vendor/symposion/reviews/views.py", line 230, in review_random_proposal
    proposals = proposals[:(len(proposals) + 1) / 2]
    TypeError: slice indices must be integers or None or have an __index__ method
This commit is contained in:
James Polley 2017-08-08 23:00:36 +00:00
parent 7b58bfafa6
commit 7fe5a09bfb

View file

@ -1,4 +1,5 @@
import csv
import math
import random
from django.contrib.auth.decorators import login_required
@ -226,8 +227,7 @@ def review_random_proposal(request, section_slug):
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]
proposals = proposals[:math.ceil(len(proposals) / 2)]
# Realistically, there shouldn't be all that many proposals to choose
# from, so this should be cheap.