﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11549	contrib.comments should allow users to specify their own template on error	Teebes	Teebes	"Currently in contrib.comments, if there is an error on the form the user is taken to a page that is generated by the preview template. This means that you can't have the user stay on the exact same page they were on if they submitted it with a mistake.

This patch introduces a new parameter to post_comment in contrib.comments.views.comments, that is None by default but that can contain an overwrite template location and extra context variable.

To get this to work, a user would just need to overwrite the comments/post url in urls.py and make it point to a custom wrapper around post_comment. For example:

urls.py:
{{{
    (r'^comments/post/$', 'thebes.quanda_comments.views.custom_post_comment'),
}}}

quanda_comments/views.py:
{{{
from django.contrib.comments.views.comments import post_comment
from django.http import HttpResponseRedirect

from thebes.quanda.models import Answer

def custom_post_comment(request):
    
    answers = Answer.objects.all()
    
    error_page = {
        'template': 'quanda/index.html',
        'data': { 'answers': answers },
    }
    response = post_comment(request, error_page=error_page)
    return response
}}}

The impact is minimal, with only one file changed and no reverse compatibility issues. I've inclued both code path and documentation patch."	New feature	closed	contrib.comments	dev	Normal	wontfix	comments, error, preview		Accepted	1	1	1	1	0	0
