Skip to content

Commit 732a7d3

Browse files
committed
Refactor dashboard views
1 parent 23e5162 commit 732a7d3

File tree

3 files changed

+4
-35
lines changed

3 files changed

+4
-35
lines changed

junction/proposals/dashboard.py

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from junction.base.constants import (
2020
ProposalReviewVote,
2121
ProposalStatus,
22-
ProposalVotesFilter,
2322
ProposalReviewStatus,
2423
)
2524
from junction.conferences.models import Conference, ConferenceProposalReviewer
@@ -238,6 +237,7 @@ def reviewer_votes_dashboard(request, conference_slug):
238237
@require_http_methods(['GET', 'POST'])
239238
def second_phase_voting(request, conference_slug):
240239
conference = get_object_or_404(Conference, slug=conference_slug)
240+
user = request.user
241241

242242
if not is_conference_moderator(user=request.user, conference=conference):
243243
raise PermissionDenied
@@ -274,36 +274,7 @@ def second_phase_voting(request, conference_slug):
274274
'errors': form.errors})
275275

276276
# 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)
307278

308279
return render(request, 'proposals/second_phase_voting.html',
309280
{'conference': conference,

junction/proposals/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ def update_reviewer_vote_info(user, psr_vote, vote_value, comment, phase, propos
7474

7575

7676
def _sort_proposals_for_dashboard(conference, proposals_qs, user, form):
77-
"""
78-
"""
7977
cps = form.cleaned_data['proposal_section']
8078
cpt = form.cleaned_data['proposal_type']
8179
votes = form.cleaned_data['votes']

junction/proposals/votes_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def proposal_reviewer_vote(request, conference_slug, proposal_slug):
142142
# Valid Form
143143
vote_value = form.cleaned_data['vote_value']
144144
comment = form.cleaned_data['comment']
145-
print(comment)
145+
146146
utils.update_reviewer_vote_info(user, psr_vote, vote_value, comment, vote_phase, proposal, conference)
147147
return HttpResponseRedirect(reverse('proposals-to-review',
148148
args=[conference.slug]))
@@ -189,7 +189,7 @@ def proposal_reviewer_secondary_vote(request, conference_slug, proposal_slug):
189189
# Valid Form
190190
vote_value = form.cleaned_data['vote_value']
191191
comment = form.cleaned_data['comment']
192-
print(comment)
192+
193193
utils.update_reviewer_vote_info(user, psr_vote, vote_value, comment, vote_phase, proposal, conference)
194194
return HttpResponseRedirect(reverse('proposals-to-review',
195195
args=[conference.slug]))

0 commit comments

Comments
 (0)