Commit d411df30 authored by chris's avatar chris

Ajouté la fonction "supprimer ses sondages"

parent c435a179
......@@ -121,6 +121,18 @@ def editchoices(request, poll_id):
vforms = OrderedItemFormset(instance=poll)
return render_to_response('sondage/choice_form.html', {'object': poll, 'vforms': vforms, 'language_code': language_code,}, context_instance=RequestContext(request))
@login_required
def delete(request, poll_id):
poll = get_object_or_404(Poll.objects.all(),id=poll_id)
if poll.author == str(request.user):
poll.delete()
return HttpResponseRedirect('/')
def make_buletin_form(poll, **kwargs):
return [ [VoteForm(prefix=choice) ] for choice in Choice.objects.filter(poll=poll.id) ]
......
......@@ -37,7 +37,7 @@
{% ifequal object.author user.username %}
<li><a href="{{ object.id }}">{{ object.title }}</a> :
<a href="{{ object.id }}/edit">{% trans "edit" %}</a> -
<a href="{{ object.id }}/delete">{% trans "delete" %}</a></li>
<a href="{{ object.id }}/delete" onclick="return confirm('{% trans "Are you sure you want to delete this poll?" %}');">{% trans "delete" %}</a></li>
{% endifequal %}
{% endfor %}
......
......@@ -34,7 +34,7 @@ urlpatterns = patterns('',
(r'^(?P<poll_id>\w{4})/$', 'nuages.sondage.views.vote'),
(r'^new/$', 'nuages.sondage.views.new'),
(r'^(?P<object_id>\w+)/edit/$', 'nuages.sondage.views.secure_update_object', dict(poll_dict, post_save_redirect='choices/')),
#(r'^(?P<poll_id>\w+)/edit/$', 'nuage.sondage.views.edit'),
(r'^(?P<poll_id>\w+)/delete/$', 'nuages.sondage.views.delete'),
(r'^(?P<poll_id>\w+)/edit/choices/$', 'nuages.sondage.views.editchoices'),
(r'^(?P<poll_id>\w{4})/vote/$', 'nuages.sondage.views.vote'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment