add button to accept / decline a proposal

This commit is contained in:
Élie Bouttier 2016-08-28 23:40:20 +02:00
parent aa78b043e2
commit 0324fd195b
4 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,26 @@
{% extends 'base.html' %}
{% load i18n %}
{% block talktab %} class="active"{% endblock %}
{% block content %}
<h1>Are you sure to {% if accept %}accept{% else %}decline{% endif %} this proposals?</h1>
<h3>Information about the proposals</h3>
<b>Title:</b> {{ talk.title }}<br />
<b>Kind:</b> {{ talk.get_event_display }}<br />
<h3>Information for the proposer</h3>
<form action="" method="post">
{% csrf_token %}
<div class="form-group">
<label for="message">If you want to send a message to the proposer, please enter it below:</label>
<textarea name="message" class="form-control" rows="5"></textarea>
</div>
<button type="submit" class="btn btn-{% if accept %}success{% else %}danger{% endif %}">{% if accept %}Accept{% else %}Decline{% endif %} the proposal</button>
<a class="btn btn-default" href="{% url 'show-talk' talk.slug %}">{% trans "Cancel" %}</a>
</form>
{% endblock %}

View File

@ -64,7 +64,13 @@
{% trans "Sum:" %} {{ talk.score }}
<h3>{% trans "Status:" %}</h3>
{{ talk.accepted|yesno:"✔,✘,?" }}
{{ talk.accepted|yesno:"Accepted,Declined,Pending decision" }}<br />
{% if talk.accepted == None %}
<a href="{% url 'accept-talk' talk.slug %}" class="btn btn-success">Accept</a>
<a href="{% url 'decline-talk' talk.slug %}" class="btn btn-danger">Decline</a>
{% endif %}
<h3>{% trans "Messages:" %}</h3>
{% for message in talk.conversation.messages.all %}

View File

@ -12,6 +12,8 @@ urlpatterns = [
url(r'^talk/vote/(?P<talk>[-\w]+)/(?P<score>[-0-2]+)$', views.vote, name='vote'),
url(r'^talk/details/(?P<slug>[-\w]+)$', views.TalkDetail.as_view(), name='show-talk'),
url(r'^talk/by-topic/(?P<topic>[-\w]+)$', views.talk_list_by_topic, name='list-talks-by-topic'),
url(r'^talk/accept/(?P<talk>[-\w]+)/$', views.talk_decide, {'accepted': True}, name='accept-talk'),
url(r'^talk/decline/(?P<talk>[-\w]+)/$', views.talk_decide, {'accepted': False}, name='decline-talk'),
url(r'^topic/$', views.TopicList.as_view(), name='list-topics'),
url(r'^topic/add/$', views.TopicCreate.as_view(), name='add-topic'),
url(r'^topic/(?P<slug>[-\w]+)/edit/$', views.TopicUpdate.as_view(), name='edit-topic'),

View File

@ -156,6 +156,22 @@ def vote(request, talk, score):
return redirect(talk.get_absolute_url())
@login_required
def talk_decide(request, talk, accepted):
talk = get_object_or_404(Talk, site=get_current_site(request), slug=talk)
if not talk.is_moderable_by(request.user):
raise PermissionDenied()
if request.method == 'POST':
talk.accepted = accepted
talk.save()
messages.success(request, _('Decision taken in account'))
return redirect('show-talk', slug=talk.slug)
return render(request, 'proposals/talk_decide.html', {
'talk': talk,
'accept': accepted,
})
@login_required
def user_details(request, username):
speaker = get_object_or_404(User, username=username)