Opened 15 years ago

Closed 12 years ago

#12018 closed New feature (wontfix)

Use "RequestContext" instead of "Context" for comments moderation email

Reported by: Charlie DeTar Owned by: nobody
Component: contrib.comments Version: dev
Severity: Normal Keywords: dceu2011
Cc: chazen@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The django.contrib.comments moderation framework allows users to send an email to site admins when a comment is posted. The email is formatted using the template "comments/comment_notification_email.txt". However, this template is rendered using a Context object, not RequestContext, making it impossible to add additional context parameters for the template renderer.

An example of the type of additional context one might want in an email is a site url, allowing the template to provide a link to the comment or admin functions on the site.

Attachments (3)

comments_request_context.diff (1.0 KB ) - added by Charlie DeTar 15 years ago.
comments_request_context2.diff (2.4 KB ) - added by Adam Vandenberg 14 years ago.
12018.diff (6.8 KB ) - added by Thejaswi Puthraya 14 years ago.
patch against the latest git checkout

Download all attachments as: .zip

Change History (13)

by Charlie DeTar, 15 years ago

comment:1 by Jannis Leidel, 15 years ago

Needs tests: set
Triage Stage: UnreviewedDesign decision needed

comment:2 by Thejaswi Puthraya, 14 years ago

As pointed out by mattmcc on IRC, this ticket doesn't address the requirement for an 'extra_context' argument. So even though a RequestContext is used, it gives access to the Request object but the context cannot be customized further.

comment:3 by Charlie DeTar, 14 years ago

Agreed -- 'extra_context' would be useful; but both would be better. RequestContext allows the context processors defined in settings.py to contribute to the context (including MEDIA_URL, etc); thus one could get extra context by adding additional context processors (at the expense of these appearing for other requests as well). 'extra_context' would allow additional parameters beyond that, or specific parameters for this case.

by Adam Vandenberg, 14 years ago

comment:4 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:5 by Thejaswi Puthraya, 14 years ago

Easy pickings: unset
Patch needs improvement: set
UI/UX: unset
Version: 1.1SVN

Not a valid patch because RequestContext's first argument must be the request object.

by Thejaswi Puthraya, 14 years ago

Attachment: 12018.diff added

patch against the latest git checkout

comment:6 by Thejaswi Puthraya, 14 years ago

Keywords: dceu2011 added
Patch needs improvement: unset

Latest patch includes tests.

comment:7 by Harro, 14 years ago

I'd argue email shouldn't be send in the request/response cycle. You often have to send e-mails outside of it.

comment:8 by Thejaswi Puthraya, 14 years ago

@hvdklauw: This patch has nothing to do with the sending of mail, it only provides the comment notification template access to the RequestContext and thus the various context processors that might have been written.

comment:9 by Harro, 14 years ago

It is, because you are rendering the email body with it.

comment:10 by Jacob, 12 years ago

Resolution: wontfix
Status: newclosed

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