Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions junction/base/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 4 additions & 0 deletions junction/proposals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from junction.base.constants import (
ConferenceSettingConstants,
ProposalReviewerComment,
ProposalReviewerVote,
ProposalReviewStatus,
ProposalStatus,
ProposalTargetAudience,
Expand Down Expand Up @@ -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'))
Expand Down
20 changes: 19 additions & 1 deletion junction/proposals/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions junction/templates/proposals/to_review.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ <h2>Proposals To Review</h2>
</div>

<hr>
{% if is_filtered %}
<a class='btn btn-info pull-left' href="./"> <i class="fa fa-list"></i> View all proposals <i class="fa fa-close"></i></a>
{% endif %}
<br/>
<div id="#proposals">
{% for section_items in proposals_to_review %}
{% if section_items.proposals %}
Expand Down
23 changes: 23 additions & 0 deletions tests/integrations/test_proposal_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down