Opened 7 years ago

Closed 3 years ago

#12018 closed New feature (wontfix)

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

Reported by: yourcelf Owned by: nobody
Component: contrib.comments Version: master
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


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 yourcelf 7 years ago.
comments_request_context2.diff (2.4 KB) - added by adamv 6 years ago.
12018.diff (6.8 KB) - added by thejaswi_puthraya 5 years ago.
patch against the latest git checkout

Download all attachments as: .zip

Change History (13)

Changed 7 years ago by yourcelf

comment:1 Changed 7 years ago by jezdez

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 6 years ago by thejaswi_puthraya

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 Changed 6 years ago by yourcelf

Agreed -- 'extra_context' would be useful; but both would be better. RequestContext allows the context processors defined in 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.

Changed 6 years ago by adamv

comment:4 Changed 5 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:5 Changed 5 years ago by thejaswi_puthraya

  • Easy pickings unset
  • Patch needs improvement set
  • UI/UX unset
  • Version changed from 1.1 to SVN

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

Changed 5 years ago by thejaswi_puthraya

patch against the latest git checkout

comment:6 Changed 5 years ago by thejaswi_puthraya

  • Keywords dceu2011 added
  • Patch needs improvement unset

Latest patch includes tests.

comment:7 Changed 5 years ago by hvdklauw

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 Changed 5 years ago by thejaswi_puthraya

@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 Changed 5 years ago by hvdklauw

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

comment:10 Changed 3 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

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; 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