|
19 | 19 | from junction.base.constants import ( |
20 | 20 | ProposalReviewVote, |
21 | 21 | ProposalStatus, |
22 | | - ProposalVotesFilter, |
23 | 22 | ProposalReviewStatus, |
24 | 23 | ) |
25 | 24 | from junction.conferences.models import Conference, ConferenceProposalReviewer |
@@ -238,6 +237,7 @@ def reviewer_votes_dashboard(request, conference_slug): |
238 | 237 | @require_http_methods(['GET', 'POST']) |
239 | 238 | def second_phase_voting(request, conference_slug): |
240 | 239 | conference = get_object_or_404(Conference, slug=conference_slug) |
| 240 | + user = request.user |
241 | 241 |
|
242 | 242 | if not is_conference_moderator(user=request.user, conference=conference): |
243 | 243 | raise PermissionDenied |
@@ -274,36 +274,7 @@ def second_phase_voting(request, conference_slug): |
274 | 274 | 'errors': form.errors}) |
275 | 275 |
|
276 | 276 | # Valid form |
277 | | - cps = form.cleaned_data['proposal_section'] |
278 | | - cpt = form.cleaned_data['proposal_type'] |
279 | | - votes = form.cleaned_data['votes'] |
280 | | - review_status = form.cleaned_data['review_status'] |
281 | | - proposal_sections = conference.proposal_sections.all() |
282 | | - |
283 | | - if cps != 'all': |
284 | | - proposal_sections = ProposalSection.objects.filter(pk=cps) |
285 | | - if cpt != 'all': |
286 | | - proposals_qs = proposals_qs.filter(proposal_type__id__in=cpt) |
287 | | - if votes != 'all': |
288 | | - votes = int(votes) |
289 | | - if review_status != 'all': |
290 | | - proposals_qs = proposals_qs.filter(review_status=review_status) |
291 | | - |
292 | | - if votes == ProposalVotesFilter.NO_VOTES: |
293 | | - proposals_qs = [ |
294 | | - p for p in proposals_qs if p.get_reviewer_votes_count() == votes] |
295 | | - elif votes == ProposalVotesFilter.MIN_ONE_VOTE: |
296 | | - proposals_qs = [ |
297 | | - p for p in proposals_qs if p.get_reviewer_votes_count() >= votes] |
298 | | - elif votes == ProposalVotesFilter.SORT: |
299 | | - proposals_qs = sorted( |
300 | | - proposals_qs, key=lambda x: x.get_reviewer_votes_sum(), |
301 | | - reverse=True) |
302 | | - |
303 | | - for section in proposal_sections: |
304 | | - section_proposals = [ |
305 | | - p for p in proposals_qs if p.proposal_section == section] |
306 | | - proposals.append(s_items(section, section_proposals)) |
| 277 | + proposals = _sort_proposals_for_dashboard(conference, proposals_qs, user, form) |
307 | 278 |
|
308 | 279 | return render(request, 'proposals/second_phase_voting.html', |
309 | 280 | {'conference': conference, |
|
0 commit comments