diff --git a/junction/base/constants.py b/junction/base/constants.py index 23f946e7..00653a9e 100644 --- a/junction/base/constants.py +++ b/junction/base/constants.py @@ -76,6 +76,12 @@ class ProposalReviewerComment: _NOT_COMMENTED = ['False', 'No'] +@choices +class ProposalReviewerVote: + _VOTED = ['True', 'Yes'] + _NOT_VOTED = ['False', 'No'] + + @choices class ProposalVotesFilter: _NO_VOTES = [0, "No votes"] 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')) diff --git a/junction/proposals/views.py b/junction/proposals/views.py index 26c76aa5..a4db89ca 100644 --- a/junction/proposals/views.py +++ b/junction/proposals/views.py @@ -298,20 +298,37 @@ 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'] 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) + 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: @@ -325,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) 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 @@