From 669b77dd2af57504b80791779889ebd85f783d9f Mon Sep 17 00:00:00 2001 From: Mohammad Faizal Date: Sat, 13 Aug 2016 14:02:50 +0400 Subject: [PATCH 1/8] Add ProposalFilter Enum --- junction/base/constants.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/junction/base/constants.py b/junction/base/constants.py index 23f946e7..d9bac76f 100644 --- a/junction/base/constants.py +++ b/junction/base/constants.py @@ -75,6 +75,11 @@ class ProposalReviewerComment: _COMMENTED = ['True', 'Yes'] _NOT_COMMENTED = ['False', 'No'] +@choices +class ProposalReviewerVote: + _VOTED = ['True', 'Yes'] + _NOT_VOTED = ['False', 'No'] + @choices class ProposalVotesFilter: From 8f2dedd48658c128500965deb6114f8ead8e49f5 Mon Sep 17 00:00:00 2001 From: Mohammad Faizal Date: Sat, 13 Aug 2016 14:03:22 +0400 Subject: [PATCH 2/8] Add reviewer vote field in filter form --- junction/proposals/forms.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/junction/proposals/forms.py b/junction/proposals/forms.py index f99315b4..594999d8 100644 --- a/junction/proposals/forms.py +++ b/junction/proposals/forms.py @@ -11,6 +11,7 @@ from junction.base.constants import ( ConferenceSettingConstants, ProposalReviewerComment, + ProposalReviewerVote, ProposalReviewStatus, ProposalStatus, ProposalTargetAudience, @@ -190,12 +191,15 @@ class ProposalsToReviewForm(ProposalTypesChoices): Used to filter proposals """ reviewer_comment = forms.ChoiceField(widget=forms.Select(attrs={'class': 'dropdown'})) + reviewer_vote = forms.ChoiceField(widget=forms.Select( + attrs={'class': 'dropdown'})) def __init__(self, conference, proposal_sections, *args, **kwargs): super(ProposalsToReviewForm, self).__init__(conference, *args, **kwargs) ps_choices = [(str(ps.id), ps.name) for ps in proposal_sections] self.fields['reviewer_comment'].choices = ProposalReviewerComment.CHOICES self.fields['proposal_section'].choices = ps_choices + self.fields['reviewer_vote'].choices = ProposalReviewerVote.CHOICES for name, field in list(self.fields.items()): field.choices.insert(0, ('all', 'All')) From eb9488a8509ae59e6fa83998ca0cf076cf7fa390 Mon Sep 17 00:00:00 2001 From: Mohammad Faizal Date: Sat, 13 Aug 2016 14:04:58 +0400 Subject: [PATCH 3/8] Add reviewer vote filter in list proposals view --- junction/proposals/views.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/junction/proposals/views.py b/junction/proposals/views.py index 26c76aa5..6a184763 100644 --- a/junction/proposals/views.py +++ b/junction/proposals/views.py @@ -305,6 +305,7 @@ def proposals_to_review(request, conference_slug): p_section = form.cleaned_data['proposal_section'] p_type = form.cleaned_data['proposal_type'] r_comment = form.cleaned_data['reviewer_comment'] + r_vote = form.cleaned_data['reviewer_vote'] if p_section != 'all': proposals_qs = proposals_qs.filter(proposal_section__id__in=p_section) @@ -312,6 +313,14 @@ def proposals_to_review(request, conference_slug): proposals_qs = proposals_qs.filter(proposal_type__id__in=p_type) if r_comment == 'True': proposals_qs = [p for p in proposals_qs if p.get_reviews_comments_count() > 0] + elif r_comment == 'False': + proposals_qs = [p for p in proposals_qs if p.get_reviews_comments_count() == 0] + if r_vote == 'True': + proposals_qs = [p for p in proposals_qs if p.get_reviewer_votes_count() > 0] + elif r_vote == 'False': + proposals_qs = [p for p in proposals_qs if p.get_reviewer_votes_count() == 0] + + proposals_to_review = [] for section in proposal_reviewer_sections: From a7653d39f8f564e6fdbb0f4719157788b52aa45f Mon Sep 17 00:00:00 2001 From: Mohammad Faizal Date: Sat, 13 Aug 2016 15:55:58 +0400 Subject: [PATCH 4/8] Fix flake8 issues --- junction/base/constants.py | 1 + junction/proposals/views.py | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/junction/base/constants.py b/junction/base/constants.py index d9bac76f..00653a9e 100644 --- a/junction/base/constants.py +++ b/junction/base/constants.py @@ -75,6 +75,7 @@ class ProposalReviewerComment: _COMMENTED = ['True', 'Yes'] _NOT_COMMENTED = ['False', 'No'] + @choices class ProposalReviewerVote: _VOTED = ['True', 'Yes'] diff --git a/junction/proposals/views.py b/junction/proposals/views.py index 6a184763..1fd0f87c 100644 --- a/junction/proposals/views.py +++ b/junction/proposals/views.py @@ -320,8 +320,6 @@ def proposals_to_review(request, conference_slug): elif r_vote == 'False': proposals_qs = [p for p in proposals_qs if p.get_reviewer_votes_count() == 0] - - proposals_to_review = [] for section in proposal_reviewer_sections: section_proposals = [p for p in proposals_qs From ee2df1e10aab0e6d246c333551abad4a4b003f0f Mon Sep 17 00:00:00 2001 From: Mohammad Faizal Date: Sat, 27 Aug 2016 21:18:03 +0400 Subject: [PATCH 5/8] Fix context on POST Request --- junction/proposals/views.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/junction/proposals/views.py b/junction/proposals/views.py index 1fd0f87c..a4db89ca 100644 --- a/junction/proposals/views.py +++ b/junction/proposals/views.py @@ -298,9 +298,13 @@ def proposals_to_review(request, conference_slug): form = ProposalsToReviewForm(data=request.POST, conference=conference, proposal_sections=proposal_reviewer_sections) if not form.is_valid(): - context['errors'] = form.errors + context = { + 'errors': form.errors + } return render(request, 'proposals/to_review.html', context) + is_filtered = False + # Valid Form p_section = form.cleaned_data['proposal_section'] p_type = form.cleaned_data['proposal_type'] @@ -309,16 +313,22 @@ def proposals_to_review(request, conference_slug): if p_section != 'all': proposals_qs = proposals_qs.filter(proposal_section__id__in=p_section) + is_filtered = True if p_type != 'all': proposals_qs = proposals_qs.filter(proposal_type__id__in=p_type) + is_filtered = True if r_comment == 'True': proposals_qs = [p for p in proposals_qs if p.get_reviews_comments_count() > 0] + is_filtered = True elif r_comment == 'False': proposals_qs = [p for p in proposals_qs if p.get_reviews_comments_count() == 0] + is_filtered = True if r_vote == 'True': proposals_qs = [p for p in proposals_qs if p.get_reviewer_votes_count() > 0] + is_filtered = True elif r_vote == 'False': proposals_qs = [p for p in proposals_qs if p.get_reviewer_votes_count() == 0] + is_filtered = True proposals_to_review = [] for section in proposal_reviewer_sections: @@ -332,6 +342,7 @@ def proposals_to_review(request, conference_slug): 'proposal_types': proposal_types, 'conference': conference, 'form': form, + 'is_filtered': is_filtered, } return render(request, 'proposals/to_review.html', context) From f05e065ca9cd38fa923360693339bb27e527bbd8 Mon Sep 17 00:00:00 2001 From: Mohammad Faizal Date: Sat, 27 Aug 2016 21:18:36 +0400 Subject: [PATCH 6/8] Add view all proposals button --- junction/templates/proposals/to_review.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/junction/templates/proposals/to_review.html b/junction/templates/proposals/to_review.html index 3a5dc38c..554b3c28 100644 --- a/junction/templates/proposals/to_review.html +++ b/junction/templates/proposals/to_review.html @@ -59,6 +59,10 @@

Proposals To Review


+ {% if is_filtered %} + View all proposals + {% endif %} +
{% for section_items in proposals_to_review %} {% if section_items.proposals %} From 19dd13a297094e8ee4b340d986fb71308959bd64 Mon Sep 17 00:00:00 2001 From: Mohammad Faizal Date: Sat, 27 Aug 2016 21:19:11 +0400 Subject: [PATCH 7/8] Add test for proposals to review view --- tests/integrations/test_proposal_views.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/integrations/test_proposal_views.py b/tests/integrations/test_proposal_views.py index 94167c56..0a760252 100644 --- a/tests/integrations/test_proposal_views.py +++ b/tests/integrations/test_proposal_views.py @@ -246,6 +246,29 @@ def test_proposal_filters(settings, login, conferences): assert response.context['is_filtered'] is True +def test_proposals_to_review_filters(settings, login, conferences, + create_reviewer): + client = login[0] + user = create_reviewer + conference = conferences['future'] + section = conference.proposal_sections.all()[1] + proposal_type = conference.proposal_types.all()[1] + f.create_proposal(conference=conference, + proposal_section=section, + proposal_type=proposal_type, + author=user) + kwargs = {'conference_slug': conference.slug} + url = reverse('proposals-to-review', kwargs=kwargs) + + response = client.post(url, {'proposal_section': section.id, + 'proposal_type': proposal_type.id, + 'reviewer_comment': 'all', + 'reviewer_vote': 'all' }) + + assert response.status_code == 200 + assert response.context['is_filtered'] is True + + def test_proposal_detail_url_redirects(client): proposal = f.create_proposal() old_url = reverse('proposal-detail', kwargs={'conference_slug': proposal.conference.slug, From 6bf7110c6135df260a6c04760a2d311252c5b73b Mon Sep 17 00:00:00 2001 From: Mohammad Faizal Date: Sat, 27 Aug 2016 21:26:30 +0400 Subject: [PATCH 8/8] Fix flak8 issues --- tests/integrations/test_proposal_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integrations/test_proposal_views.py b/tests/integrations/test_proposal_views.py index 0a760252..0b3d874c 100644 --- a/tests/integrations/test_proposal_views.py +++ b/tests/integrations/test_proposal_views.py @@ -263,7 +263,7 @@ def test_proposals_to_review_filters(settings, login, conferences, response = client.post(url, {'proposal_section': section.id, 'proposal_type': proposal_type.id, 'reviewer_comment': 'all', - 'reviewer_vote': 'all' }) + 'reviewer_vote': 'all'}) assert response.status_code == 200 assert response.context['is_filtered'] is True