Changeset - f3fc572ca759
[Not reviewed]
Merge
0 1 0
Scott Bragg - 8 years ago 2016-08-17 04:28:32
jsbragg@scriptforge.org
Merge pull request #48 from lca2017/chrisjrn/20160817

Review tweaks
1 file changed with 17 insertions and 7 deletions:
0 comments (0 inline, 0 general)
symposion/reviews/views.py
Show inline comments
...
 
@@ -164,13 +164,14 @@ def review_all_proposals_csv(request):
 
    writer.writerow(fields)
 

	
 
    for proposal in proposals_generator(request, queryset, check_speaker=False):
 

	
 
        proposal.speaker_name = proposal.speaker.name
 
        section_slug = proposal.kind.section.slug
 
        proposal.proposal_type = section_slug
 
        kind_slug = proposal.kind.slug
 
        proposal.proposal_type = kind_slug
 

	
 
        if not request.user.has_perm("reviews.can_review_%s" % section_slug):
 
            continue
 

	
 
        csv_line = [getattr(proposal, field) for field in fields]
 

	
...
 
@@ -201,22 +202,30 @@ def review_random_proposal(request, section_slug):
 

	
 
    if len(queryset) == 0:
 
        return redirect("review_section", section_slug=section_slug, reviewed="all")
 

	
 
    # Direct reviewers to underreviewed proposals
 
    too_few_set = REVIEW_STATUS_FILTERS[TOO_FEW](queryset)
 
    indifferent_set = REVIEW_STATUS_FILTERS[INDIFFERENT](queryset)
 
    controversial_set = REVIEW_STATUS_FILTERS[CONTROVERSIAL](queryset)
 

	
 
    if len(too_few_set) > 0:
 
        queryset = too_few_set
 
    elif len(indifferent_set) > 0:
 
        queryset = indifferent_set
 
        proposals = too_few_set.all()
 
    elif len(controversial_set) > 0:
 
        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)
 

	
 

	
 
@login_required
 
def review_list(request, section_slug, user_pk):
 

	
...
 
@@ -225,12 +234,13 @@ def review_list(request, section_slug, user_pk):
 
    if not request.user.has_perm("reviews.can_manage_%s" % section_slug):
 
        if not request.user.pk == user_pk:
 
            return access_not_permitted(request)
 

	
 
    queryset = ProposalBase.objects.select_related("speaker__user", "result")
 
    reviewed = LatestVote.objects.filter(user__pk=user_pk).values_list("proposal", flat=True)
 
    queryset = queryset.filter(kind__section__slug=section_slug)
 
    queryset = queryset.filter(pk__in=reviewed)
 
    proposals = queryset.order_by("submitted")
 

	
 
    admin = request.user.has_perm("reviews.can_manage_%s" % section_slug)
 

	
 
    proposals = proposals_generator(request, proposals, user_pk=user_pk, check_speaker=not admin)
...
 
@@ -258,13 +268,13 @@ def review_admin(request, section_slug):
 
                already_seen.add(user.pk)
 

	
 
                user.comment_count = Review.objects.filter(
 
                    user=user,
 
                    proposal__kind__section__slug=section_slug,
 
                ).count()
 
                
 

 
                user_votes = LatestVote.objects.filter(
 
                    user=user,
 
                    proposal__kind__section__slug=section_slug,
 
                )
 
                print section_slug
 
                print [vote.proposal.kind.section.slug for vote in user_votes]
0 comments (0 inline, 0 general)