- changed status to invalid
Can't access to message object in notifier template
Postman and notification sends variables with the same names in templates:
postman (utils.py): {{{ if notification: notification.send(users=[user], label=label, extra_context={'message': object, 'action': action}) }}}
notification (models.py): {{{ body = render_to_string("notification/email_body.txt", { "message": messages["full.txt"], }, context) }}}
Comments (7)
-
reporter -
reporter Sorry, it's ok ))
-
repo owner -
assigned issue to
- changed status to open
Can you explain why you gave up this issue? After investigations, I believe your report is valid.
The Postman message object is available for the rendering of some of the Notification templates, such as 'full.txt'. But it is probably no more for the rendering of 'email_subject.txt' and 'email_body.txt' because of the name conflict.
Can you confirm that?
I plan to avoid this clash and be safer, by renaming my variables like so:
notification.send(users=[user], label=label, extra_context={'pm_message': object, 'pm_action': action})
-
assigned issue to
-
repo owner Issue
#14was marked as a duplicate of this issue. -
reporter This name conflict problem occurs only in email_body.txt and email_subject.txt notification templates:
context = Context({ "recipient": user, "sender": sender, "notice": ugettext(notice_type.display), "notices_url": notices_url, "current_site": current_site, }) # Postman vars insert in context here: context.update(extra_context) # Here is basic templates (full.html, full.txt, notice.html, short.txt) render : messages = get_formatted_messages(formats, label, context) # And here notification replaces 'message' var: subject = "".join(render_to_string("notification/email_subject.txt", { "message": messages["short.txt"], }, context).splitlines()) body = render_to_string("notification/email_body.txt", { "message": messages["full.txt"], }, context)
So, vars renaming is a good idea anyway to have access them in email_body.txt and email_subject.txt.
-
repo owner New variable names are commited.
-
repo owner - changed status to resolved
- Log in to comment