Changeset - 5fefff0a3dbd
[Not reviewed]
0 3 0
Brian Rosner - 12 years ago 2012-09-08 00:11:43
brosner@gmail.com
added result_notification_prepare view and stubbed out result_notification_send
3 files changed with 83 insertions and 38 deletions:
0 comments (0 inline, 0 general)
symposion/reviews/urls.py
Show inline comments
...
 
@@ -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/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+)/prepare/$", "result_notification_prepare", name="result_notification_prepare"),
 
    
 
    url(r"^review/(?P<pk>\d+)/$", "review_detail", name="review_detail"),
 
    
symposion/reviews/views.py
Show inline comments
 
from django.db.models import Q
 
from django.http import HttpResponseBadRequest, HttpResponseNotAllowed
 
from django.shortcuts import render, redirect, get_object_or_404
 
from django.views.decorators.http import require_POST
 

	
...
 
@@ -377,9 +378,44 @@ def result_notification(request, section_slug, status):
 
        return access_not_permitted(request)
 
    
 
    proposals = ProposalBase.objects.filter(kind__section__slug=section_slug, result__status=status).select_related("speaker__user", "result").select_subclasses()
 

 
    
 
    ctx = {
 
        "section_slug": section_slug,
 
        "status": status,
 
        "proposals": proposals,
 
    }
 
    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
symposion/templates/reviews/result_notification.html
Show inline comments
...
 
@@ -15,44 +15,52 @@
 
    
 
    <span class="action-counter">0</span> selected
 
    
 
    <table class="table table-striped table-bordered">
 
        <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>
 
    <form method="post" action="{% url result_notification_prepare section_slug status %}">
 
        
 
        <tbody>
 
            {% for proposal in proposals %}
 
                <tr>
 
                    <td><input class="action-select" type="checkbox" name="_selected_action" value="{{ proposal.pk }}"></td>
 
                    <td>{{ proposal.number }}</td>
 
                    <td>
 
                        <a href="{% url review_detail proposal.pk %}">
 
                            <small><strong>{{ proposal.speaker }}</strong></small>
 
                            <br />
 
                            {{ proposal.title }}
 
                        </a>
 
                    </td>
 
                    <td>{{ proposal.track }}</td>
 
                    <td>
 
                        {% with proposal.result.status as status %}
 
                            <div class="{{ status }}">
 
                                {% if status != "undecided" %}
 
                                    <span>{{ status }}</span>
 
                                {% endif %}
 
                            </div>
 
                        {% endwith %}
 
                    </td>
 
                    <td>
 
                    </td>
 
                </tr>
 
            {% endfor %}
 
        </tbody>
 
    </table>
 
        {% csrf_token %}
 
        
 
        <table class="table table-striped table-bordered">
 
            <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>
 
                {% for proposal in proposals %}
 
                    <tr>
 
                        <td><input class="action-select" type="checkbox" name="_selected_action" value="{{ proposal.pk }}"></td>
 
                        <td>{{ proposal.number }}</td>
 
                        <td>
 
                            <a href="{% url review_detail proposal.pk %}">
 
                                <small><strong>{{ proposal.speaker }}</strong></small>
 
                                <br />
 
                                {{ proposal.title }}
 
                            </a>
 
                        </td>
 
                        <td>{{ proposal.track }}</td>
 
                        <td>
 
                            {% with proposal.result.status as status %}
 
                                <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 %}
 

	
 
{% block extra_script %}
0 comments (0 inline, 0 general)