added result_notification_prepare view and stubbed out result_notification_send

This commit is contained in:
Brian Rosner 2012-09-07 18:11:43 -06:00
parent 3c2a0de89d
commit 5fefff0a3d
3 changed files with 83 additions and 38 deletions

View file

@ -10,6 +10,7 @@ urlpatterns = patterns("symposion.reviews.views",
url(r"^section/(?P<section_slug>[\w\-]+)/admin/$", "review_admin", name="review_admin"), url(r"^section/(?P<section_slug>[\w\-]+)/admin/$", "review_admin", name="review_admin"),
url(r"^section/(?P<section_slug>[\w\-]+)/admin/accept/$", "review_bulk_accept", name="review_bulk_accept"), url(r"^section/(?P<section_slug>[\w\-]+)/admin/accept/$", "review_bulk_accept", name="review_bulk_accept"),
url(r"^section/(?P<section_slug>[\w\-]+)/notification/(?P<status>\w+)/$", "result_notification", name="result_notification"), url(r"^section/(?P<section_slug>[\w\-]+)/notification/(?P<status>\w+)/$", "result_notification", name="result_notification"),
url(r"^section/(?P<section_slug>[\w\-]+)/notification/(?P<status>\w+)/prepare/$", "result_notification_prepare", name="result_notification_prepare"),
url(r"^review/(?P<pk>\d+)/$", "review_detail", name="review_detail"), url(r"^review/(?P<pk>\d+)/$", "review_detail", name="review_detail"),

View file

@ -1,4 +1,5 @@
from django.db.models import Q from django.db.models import Q
from django.http import HttpResponseBadRequest, HttpResponseNotAllowed
from django.shortcuts import render, redirect, get_object_or_404 from django.shortcuts import render, redirect, get_object_or_404
from django.views.decorators.http import require_POST from django.views.decorators.http import require_POST
@ -377,9 +378,44 @@ def result_notification(request, section_slug, status):
return access_not_permitted(request) return access_not_permitted(request)
proposals = ProposalBase.objects.filter(kind__section__slug=section_slug, result__status=status).select_related("speaker__user", "result").select_subclasses() proposals = ProposalBase.objects.filter(kind__section__slug=section_slug, result__status=status).select_related("speaker__user", "result").select_subclasses()
ctx = { ctx = {
"section_slug": section_slug, "section_slug": section_slug,
"status": status,
"proposals": proposals, "proposals": proposals,
} }
return render(request, "reviews/result_notification.html", ctx) return render(request, "reviews/result_notification.html", ctx)
@login_required
def result_notification_prepare(request, section_slug, status):
if request.method != "POST":
return HttpResponseNotAllowed(["POST"])
proposal_pks = []
try:
for pk in request.POST.getlist("_selected_action"):
proposal_pks.append(int(pk))
except ValueError:
return HttpResponseBadRequest()
proposals = ProposalBase.objects.filter(
kind__section__slug=section_slug,
result__status=status,
)
proposals = proposals.filter(pk__in=proposal_pks)
proposals = proposals.select_related("speaker__user", "result")
proposals = proposals.select_subclasses()
ctx = {
"section_slug": section_slug,
"status": status,
"proposals": proposals,
}
return render(request, "reviews/result_notification_prepare.html", ctx)
def result_notification_send(request, section_slug, status):
if request.method != "POST":
return HttpResponseNotAllowed(["POST"])
# @@@ discuss with jtauber about how to handle this

View file

@ -15,44 +15,52 @@
<span class="action-counter">0</span> selected <span class="action-counter">0</span> selected
<table class="table table-striped table-bordered"> <form method="post" action="{% url result_notification_prepare section_slug status %}">
<thead>
<th><input type="checkbox" id="action-toggle"></th>
<th>#</th>
<th>{% trans "Speaker / Title" %}</th>
<th>{% trans "Category" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Notified?" %}</th>
</thead>
<tbody> {% csrf_token %}
{% for proposal in proposals %}
<tr> <table class="table table-striped table-bordered">
<td><input class="action-select" type="checkbox" name="_selected_action" value="{{ proposal.pk }}"></td> <thead>
<td>{{ proposal.number }}</td> <th><input type="checkbox" id="action-toggle"></th>
<td> <th>#</th>
<a href="{% url review_detail proposal.pk %}"> <th>{% trans "Speaker / Title" %}</th>
<small><strong>{{ proposal.speaker }}</strong></small> <th>{% trans "Category" %}</th>
<br /> <th>{% trans "Status" %}</th>
{{ proposal.title }} <th>{% trans "Notified?" %}</th>
</a> </thead>
</td>
<td>{{ proposal.track }}</td> <tbody>
<td> {% for proposal in proposals %}
{% with proposal.result.status as status %} <tr>
<div class="{{ status }}"> <td><input class="action-select" type="checkbox" name="_selected_action" value="{{ proposal.pk }}"></td>
{% if status != "undecided" %} <td>{{ proposal.number }}</td>
<span>{{ status }}</span> <td>
{% endif %} <a href="{% url review_detail proposal.pk %}">
</div> <small><strong>{{ proposal.speaker }}</strong></small>
{% endwith %} <br />
</td> {{ proposal.title }}
<td> </a>
</td> </td>
</tr> <td>{{ proposal.track }}</td>
{% endfor %} <td>
</tbody> {% with proposal.result.status as status %}
</table> <div class="{{ status }}">
{% if status != "undecided" %}
<span>{{ status }}</span>
{% endif %}
</div>
{% endwith %}
</td>
<td>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<button type="submit" class="btn btn-primary">POST IT</button>
</form>
{% endblock %} {% endblock %}
{% block extra_script %} {% block extra_script %}