Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changed template names and other things

git-svn-id: https://django-notification.googlecode.com/svn/trunk@71 590c3fc9-4838-0410-bb95-17a0c9b37ca9
  • Loading branch information...
commit ccdd0791cdb4d40800c004308e68cae21088a97a 1 parent 6016a0a
@jezdez jezdez authored
View
28 notification/models.py
@@ -174,9 +174,10 @@ def get_formatted_messages(formats, label, context):
"""
format_templates = {}
for format in formats:
- format_templates[format] = render_to_string((
- 'notification/%s/%s.html' % (label, format),
- 'notification/%s.html' % format), context)
+ name = format.split(".")[0]
+ format_templates[name] = render_to_string((
+ 'notification/%s/%s' % (label, format),
+ 'notification/%s' % format), context)
return format_templates
def send(recipient, label, extra_context={}, issue_notice=True):
@@ -211,7 +212,12 @@ def send(recipient, label, extra_context={}, issue_notice=True):
recipients = []
current_language = get_language()
- formats = ('short', 'plain', 'full') # TODO make that formats configurable
+ formats = (
+ 'short.txt'
+ 'plain.txt',
+ 'teaser.html',
+ 'full.html',
+ ) # TODO make formats configurable
for user in recipient:
# get user profiles if available
@@ -228,13 +234,23 @@ def send(recipient, label, extra_context={}, issue_notice=True):
# activate the user's language
activate(language)
+ # get prerendered format messages
messages = get_formatted_messages(formats, label, context)
+ # Strip newlines from subject
+ subject = ''.join(render_to_string('notification/email_subject.txt', {
+ 'message': messages['short'],
+ }, context).splitlines())
+
+ body = render_to_string('notification/email_body.txt', {
+ 'message': messages['plain'],
+ }, context)
+
if issue_notice:
- notice = Notice.objects.create(user=user, message=messages['full'], notice_type=notice_type)
+ notice = Notice.objects.create(user=user, message=messages['teaser'], notice_type=notice_type)
if should_send(user, notice_type, "1") and user.email: # Email
recipients.append(user.email)
- send_mail(messages['short'], messages['plain'], settings.DEFAULT_FROM_EMAIL, recipients)
+ send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, recipients)
# reset environment to original language
activate(current_language)
View
5 notification/templates/notification/plain.html → notification/templates/notification/email_body.txt
@@ -1,7 +1,6 @@
{% load i18n %}{% blocktrans %}You have received the following notice from {{ current_site }}:
-{{ notice }}
+{{ message }}
-To see other notices or change how you receive notifications,
-please go to {{ notices_url }}.
+To see other notices or change how you receive notifications, please go to {{ notices_url }}.
{% endblocktrans %}
View
1  notification/templates/notification/email_subject.txt
@@ -0,0 +1 @@
+{% load i18n %}{% blocktrans %}[{{ current_site }}] {{ message }}{% endblocktrans %}
View
0  notification/templates/notification/full.html → notification/templates/notification/plain.txt
File renamed without changes
View
1  notification/templates/notification/short.html
@@ -1 +0,0 @@
-{% load i18n %}{% blocktrans %}{{ notice }} - {{ current_site }}{% endblocktrans %}
View
1  notification/templates/notification/short.txt
@@ -0,0 +1 @@
+{% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %}
View
1  notification/templates/notification/teaser.html
@@ -0,0 +1 @@
+{% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %}
Please sign in to comment.
Something went wrong with that request. Please try again.