From 2a6c19244936e23af23eb71153ec53b30ab53145 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Mon, 15 Aug 2016 10:17:27 +1000 Subject: [PATCH 1/5] Refactors the CSV piece to be nicer than it previously was. --- symposion/reviews/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/symposion/reviews/views.py b/symposion/reviews/views.py index 6531b20e..b4dd8d99 100644 --- a/symposion/reviews/views.py +++ b/symposion/reviews/views.py @@ -147,6 +147,10 @@ def review_all_proposals_csv(request): ''' Returns a CSV representation of all of the proposals this user has permisison to review. ''' + response = HttpResponse("text/csv") + response['Content-Disposition'] = 'attachment; filename="proposals.csv"' + writer = csv.writer(response, quoting=csv.QUOTE_NONNUMERIC) + queryset = ProposalBase.objects.filter() # The fields from each proposal object to report in the csv @@ -156,9 +160,6 @@ def review_all_proposals_csv(request): "score", "total_votes", "minus_two", "minus_one", "plus_one", "plus_two", ] - output = StringIO.StringIO() - writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC) - # Fields are the heading writer.writerow(fields) @@ -180,7 +181,7 @@ def review_all_proposals_csv(request): writer.writerow(csv_line) - return HttpResponse(output.getvalue(), "text/csv") + return response @login_required From 3217f43af2c5a296e7e76225dce5186a082eb027 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Mon, 15 Aug 2016 10:41:51 +1000 Subject: [PATCH 2/5] Adds abstains and averages to the reviewers scores list. --- symposion/reviews/views.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/symposion/reviews/views.py b/symposion/reviews/views.py index b4dd8d99..97ccb156 100644 --- a/symposion/reviews/views.py +++ b/symposion/reviews/views.py @@ -258,23 +258,30 @@ def review_admin(request, section_slug): already_seen.add(user.pk) user.comment_count = Review.objects.filter(user=user).count() - user.total_votes = LatestVote.objects.filter(user=user).count() - user.plus_two = LatestVote.objects.filter( - user=user, - vote=LatestVote.VOTES.PLUS_TWO + user_votes = LatestVote.objects.filter( + user=user + ) + user.total_votes = user_votes.exclude( + vote=LatestVote.VOTES.ABSTAIN, ).count() - user.plus_one = LatestVote.objects.filter( - user=user, - vote=LatestVote.VOTES.PLUS_ONE + user.plus_two = user_votes.filter( + vote=LatestVote.VOTES.PLUS_TWO, ).count() - user.minus_one = LatestVote.objects.filter( - user=user, - vote=LatestVote.VOTES.MINUS_ONE + user.plus_one = user_votes.filter( + vote=LatestVote.VOTES.PLUS_ONE, ).count() - user.minus_two = LatestVote.objects.filter( - user=user, - vote=LatestVote.VOTES.MINUS_TWO + user.minus_one = user_votes.filter( + vote=LatestVote.VOTES.MINUS_ONE, ).count() + user.minus_two = user_votes.filter( + vote=LatestVote.VOTES.MINUS_TWO, + ).count() + user.abstain = user_votes.filter( + vote=LatestVote.VOTES.ABSTAIN, + ).count() + user.average = ( + user.plus_two + user.plus_one + user.minus_one + user.minus_two + ) / (user.total_votes * 1.0) yield user From 24f8ac875711263bb346eb24aaec9eecd3c1f773 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Mon, 15 Aug 2016 10:44:44 +1000 Subject: [PATCH 3/5] Makes the reviewer proposals list render properly --- symposion/reviews/urls.py | 2 +- symposion/reviews/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/symposion/reviews/urls.py b/symposion/reviews/urls.py index 6c35f3bb..6f8e9c43 100644 --- a/symposion/reviews/urls.py +++ b/symposion/reviews/urls.py @@ -25,7 +25,7 @@ urlpatterns = [ url(r"^section/(?P[\w\-]+)/assignments/$", review_section, {"assigned": True}, name="review_section_assignments"), url(r"^section/(?P[\w\-]+)/status/$", review_status, name="review_status"), url(r"^section/(?P[\w\-]+)/status/(?P\w+)/$", review_status, name="review_status"), - url(r"^section/(?P[\w\-]+)/list/(?P\d+)/$", review_list, name="review_list_user"), + url(r"^section/(?P[\w\-]+)/list_reviewer/(?P\d+)/$", review_list, name="review_list_user"), url(r"^section/(?P[\w\-]+)/admin/$", review_admin, name="review_admin"), url(r"^section/(?P[\w\-]+)/admin/accept/$", review_bulk_accept, name="review_bulk_accept"), url(r"^section/(?P[\w\-]+)/notification/(?P\w+)/$", result_notification, name="result_notification"), diff --git a/symposion/reviews/views.py b/symposion/reviews/views.py index 97ccb156..605051e6 100644 --- a/symposion/reviews/views.py +++ b/symposion/reviews/views.py @@ -238,7 +238,7 @@ def review_list(request, section_slug, user_pk): ctx = { "proposals": proposals, } - return (request, "symposion/reviews/review_list.html", ctx) + return render(request, "symposion/reviews/review_list.html", ctx) @login_required From 9ae17146df49675270e74b024ca3a6b9ec7a6330 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Mon, 15 Aug 2016 11:11:25 +1000 Subject: [PATCH 4/5] More work on the reviewers list --- symposion/reviews/views.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/symposion/reviews/views.py b/symposion/reviews/views.py index 605051e6..a9c3d7f5 100644 --- a/symposion/reviews/views.py +++ b/symposion/reviews/views.py @@ -259,8 +259,11 @@ def review_admin(request, section_slug): user.comment_count = Review.objects.filter(user=user).count() user_votes = LatestVote.objects.filter( - user=user + user=user, + proposal__kind__section__slug=section_slug, ) + print section_slug + print [vote.proposal.kind.section.slug for vote in user_votes] user.total_votes = user_votes.exclude( vote=LatestVote.VOTES.ABSTAIN, ).count() @@ -279,9 +282,13 @@ def review_admin(request, section_slug): user.abstain = user_votes.filter( vote=LatestVote.VOTES.ABSTAIN, ).count() - user.average = ( - user.plus_two + user.plus_one + user.minus_one + user.minus_two - ) / (user.total_votes * 1.0) + if user.total_votes == 0: + user.average = "-" + else: + user.average = ( + user.plus_two + user.plus_one + + user.minus_one + user.minus_two + ) / (user.total_votes * 1.0) yield user From 9223c8fc909214c59d02f42c473cb417bc3d4796 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Mon, 15 Aug 2016 12:22:40 +1000 Subject: [PATCH 5/5] =?UTF-8?q?Adds=20=E2=80=9CSubmit=20review=20and=20jum?= =?UTF-8?q?p=20to=20random=20proposal=E2=80=9D=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- symposion/reviews/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/symposion/reviews/views.py b/symposion/reviews/views.py index a9c3d7f5..e74a1193 100644 --- a/symposion/reviews/views.py +++ b/symposion/reviews/views.py @@ -325,7 +325,7 @@ def review_detail(request, pk): if request.user in speakers: return access_not_permitted(request) - if "vote_submit" in request.POST: + if "vote_submit" in request.POST or "vote_submit_and_random" in request.POST: review_form = ReviewForm(request.POST) if review_form.is_valid(): @@ -334,7 +334,13 @@ def review_detail(request, pk): review.proposal = proposal review.save() - return redirect(request.path) + if "vote_submit_and_random" in request.POST: + next_page = redirect("user_random", proposal.kind.section.slug) + next_page["Location"] += "#invalid_fragment" # Hack. + else: + next_page = redirect(request.path) + + return next_page else: message_form = SpeakerCommentForm() elif "message_submit" in request.POST and admin: