Opened 15 years ago

Closed 12 years ago

#11549 closed New feature (wontfix)

contrib.comments should allow users to specify their own template on error

Reported by: Teebes Owned by: Teebes
Component: contrib.comments Version: dev
Severity: Normal Keywords: comments, error, preview
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

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.

Attachments (1)

comments_patch.diff (3.0 KB ) - added by Teebes 15 years ago.
Patch to contrib.comments (code & documentation) to allow error template selection

Download all attachments as: .zip

Change History (9)

by Teebes, 15 years ago

Attachment: comments_patch.diff added

Patch to contrib.comments (code & documentation) to allow error template selection

comment:1 by Teebes, 15 years ago

Owner: changed from nobody to Teebes
Status: newassigned

comment:3 by Russell Keith-Magee, 15 years ago

Triage Stage: UnreviewedAccepted

Nothing wrong with the idea, but it should be implemented in a way that maintains parity with other configurable template views (like the generic views). This means passing in a template_name and extra_context arguments, rather than a dictionary.

comment:4 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:5 by Julien Phalip, 14 years ago

Needs documentation: set
Needs tests: set
Patch needs improvement: set

Patch needs improvement as per Russell's comment. Also needs tests and (better) doc to reflect the requested improvement.

comment:6 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:7 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:8 by Jacob, 12 years ago

Resolution: wontfix
Status: assignedclosed

django.contrib.comments has been deprecated and is no longer supported, so I'm closing this ticket. We're encouraging users to transition to a custom solution, or to a hosted solution like Disqus.

The code itself has moved to https://github.com/django/django-contrib-comments; if you want to keep using it, you could move this bug over there.

Note: See TracTickets for help on using tickets.
Back to Top