Skip to content

Commit 27d3993

Browse files
authored
Merge pull request #483 from pythonindia/issue_481
Add proposal state view
2 parents 5ece6bf + e51f2f9 commit 27d3993

File tree

5 files changed

+132
-3
lines changed

5 files changed

+132
-3
lines changed

junction/proposals/dashboard.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
ProposalSectionReviewerVoteValue
3535
)
3636

37+
from . import services
38+
3739

3840
@login_required
3941
@require_http_methods(['GET'])
@@ -327,3 +329,20 @@ def export_reviewer_votes(request, conference_slug):
327329
response['Content-Disposition'] = "attachment; filename=junction-{}.xlsx".format(file_name)
328330

329331
return response
332+
333+
334+
@login_required
335+
@require_http_methods(['GET'])
336+
def proposal_state(request, conference_slug):
337+
conf = get_object_or_404(Conference, slug=conference_slug)
338+
339+
if not is_conference_moderator(user=request.user, conference=conf):
340+
raise PermissionDenied
341+
342+
state = request.GET.get('q', 'unreviewed')
343+
proposals = services.group_proposals_by_reveiew_state(conf=conf, state=state)
344+
345+
return render(request, 'proposals/review_state.html',
346+
{'conference': conf,
347+
'proposals': proposals,
348+
'state': state.title()})

junction/proposals/services.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# -*- coding: utf-8 -*-
2+
23
from __future__ import absolute_import, unicode_literals
34

45
# Standard Library
56
import logging
7+
import collections
68

79
# Third Party Stuff
810
from django.conf import settings
911
from markdown2 import markdown
1012

1113
# Junction Stuff
1214
from junction.base.emailer import send_email
15+
from junction.base.constants import ProposalStatus
1316

1417
from .models import ProposalSection, ProposalSectionReviewer
1518

@@ -111,4 +114,30 @@ def send_mail_for_proposal_content(conference, proposal, host):
111114
'proposal': proposal,
112115
'author_name': author_name,
113116
}
114-
return send_email(to=author, template_dir='proposals/email/upload_content', context=context)
117+
return send_email(to=author, template_dir='proposals/email/upload_content',
118+
context=context)
119+
120+
121+
def group_proposals_by_reveiew_state(conf, state='reviewed'):
122+
reviewed_qs = conf.proposal_set.filter(
123+
status=ProposalStatus.PUBLIC).select_related(
124+
'proposal_type', 'proposal_section',
125+
'proposalsection').filter(proposalcomment__private=True,
126+
proposalcomment__deleted=False)
127+
if state == 'reviewed':
128+
proposal_qs = reviewed_qs.distinct()
129+
return _arrange_proposals_by_section(proposal_qs)
130+
else:
131+
ids = reviewed_qs.values_list('id').distinct()
132+
qs = conf.proposal_set.filter(
133+
status=ProposalStatus.PUBLIC).select_related(
134+
'proposal_type', 'proposal_section',
135+
'proposalsection').exclude(pk__in=ids)
136+
return _arrange_proposals_by_section(qs)
137+
138+
139+
def _arrange_proposals_by_section(proposal_qs):
140+
res = collections.defaultdict(list)
141+
for proposal in proposal_qs:
142+
res[proposal.proposal_section.name].append(proposal)
143+
return res

junction/templates/proposals/dashboard.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@
8888
<tr>
8989
<th>Type Name</th>
9090
<th>Total</th>
91-
<th>Reviewed</th>
92-
<th>UnReviewed</th>
91+
<th><a href="{% url 'proposal-state' conference.slug%}?q='reviewed' %}">
92+
Reviewed</a></th>
93+
<th><a href="{% url 'proposal-state' conference.slug%}?q='unreviewed' %}">
94+
UnReviewed</a></th>
9395
</tr>
9496
{% for group,count in group_by_type.items %}
9597
<tr>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{% extends 'base.html' %}
2+
3+
{% load django_markdown %}
4+
{% load static from staticfiles %}
5+
{% load django_bootstrap_breadcrumbs %}
6+
7+
{% block head_title %} {{ conference.name }} Reviewers dashbaord {% endblock %}
8+
{% block og_title %} {{ conference.name }} Reviewers dashboard {% endblock %}
9+
{% block og_description %} {{ conference.description|markdown|safe|striptags}} {% endblock %}
10+
{% block page_description %} {{ conference.description|markdown|safe|striptags}} {% endblock %}
11+
12+
{% block endhead %}
13+
<!-- Custom CSS -->
14+
<link href="{% static 'css/list.css' %}" rel="stylesheet">
15+
{% endblock %}
16+
17+
{% block breadcrumbs %}
18+
{{ block.super }}
19+
{% breadcrumb conference.name "conference-detail" conference.slug %}
20+
{% breadcrumb "Dashboard" "proposals-dashoboard" conference.slug %}
21+
{% endblock %}
22+
23+
24+
{% block navbar_logo %}
25+
{% if conference.logo %}
26+
<a href="{% url "conference-detail" conference.slug %}">
27+
<img src="{{ conference.logo.url }}">
28+
</a>
29+
{% else %}
30+
<a href="#" class="navbar-brand">{{ conference.name }}</a>
31+
{% endif %}
32+
{% endblock navbar_logo %}
33+
34+
{% block page_classes %}{{ block.super}} page-proposals{% endblock page_classes %}
35+
36+
{% block content %}
37+
<section class="content custom-container proposal-list">
38+
<div class="push-4-bottom push-1-top">
39+
<div class="row">
40+
<div class="col-xs -12 col-sm-12 ">
41+
<p class="meta">
42+
<b class="text-muted">
43+
<span class="start_date">{{ conference.start_date }}</span>
44+
<span class="end_date">{{ conference.end_date }}</span>
45+
</b>
46+
<span class="status status-{{conference.status}}">
47+
{{ conference.get_status_display }}
48+
</span>
49+
</p>
50+
<hr>
51+
</div>
52+
</div>
53+
</div>
54+
55+
<div class="row">
56+
<div class="col-xs -6 col-sm-6 ">
57+
<div class="panel panel-primary">
58+
<div class="panel-heading"> {{ state }} proposals</div>
59+
<div class="panel-body">
60+
{% for section, proposal_list in proposals.items %}
61+
<h2 class="section-title">{{ section }}</h2>
62+
{% for proposal in proposal_list %}
63+
<h3 class="proposal--title">
64+
<a href='{{ proposal.get_absolute_url }}'>{{ forloop.counter}}. {{ proposal.title|capfirst }}</a>
65+
- {{ proposal.proposal_type }}
66+
</h3>
67+
{% endfor %}
68+
{% endfor %}
69+
</div>
70+
</div>
71+
</div>
72+
</div>
73+
74+
</div>
75+
</section>
76+
{% endblock %}

junction/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
url(r'^(?P<conference_slug>[\w-]+)/dashboard/reviewers/',
5353
'junction.proposals.dashboard.reviewer_comments_dashboard',
5454
name='proposal-reviewers-dashboard'),
55+
url(r'^(?P<conference_slug>[\w-]+)/dashboard/proposal_state/$',
56+
'junction.proposals.dashboard.proposal_state',
57+
name='proposal-state'),
5558
url(r'^(?P<conference_slug>[\w-]+)/dashboard/$',
5659
'junction.proposals.dashboard.proposals_dashboard', name='proposal-dashboard'),
5760
url(r'^(?P<conference_slug>[\w-]+)/dashboard/votes/$',

0 commit comments

Comments
 (0)