Esempio n. 1
0
def delete_comment(request):
    if request.method == "POST":
        form = DeleteCommentForm(request.POST)
        if form.is_valid():
            client = get_object_or_404(Client,
                                       pk=form.cleaned_data['client_id'])
            comment = get_object_or_404(Comment,
                                        pk=form.cleaned_data['comment_id'])
            selection = get_object_or_404(Selection,
                                          pk=form.cleaned_data['selection_id'])
            comment.delete()
            return HttpResponseRedirect(request.META.get('HTTP_REFERER'), {
                'selection': selection,
                'client': client
            })
        else:
            raise Http404("That page does not exist")
    else:
        raise Http404("That page does not exist")