Touching up emails. Subject to change, but these will do for now

This commit is contained in:
Paul Osman 2011-01-09 21:51:39 -05:00
Родитель 7a6b78cdbe
Коммит 54490dc9c4
5 изменённых файлов: 45 добавлений и 4 удалений

Просмотреть файл

@ -1,4 +1,7 @@
from django.core.urlresolvers import reverse
from django.db.models.signals import post_save
from django.utils.translation import ugettext as _
from django.template.loader import render_to_string
from messages.models import Message
from users.tasks import SendUserEmail
@ -19,7 +22,16 @@ def message_sent_handler(sender, **kwargs):
for preference in preferences:
if preference.value and preference.key == 'no_email_message_received':
return
subject = 'Private Message from %s' % (message.sender.get_profile().name,)
body = "" # todo - write some copy for this
sender = message.sender.get_profile().name
subject = _('New Message from %(name)s' % {
'name': sender,
})
body = render_to_string('drumbeatmail/emails/direct_message.txt', {
'sender': sender,
'message': message.body,
'reply_url': reverse('drumbeatmail_reply', kwargs={
'message': message.pk,
}),
})
SendUserEmail.apply_async((user.get_profile(), subject, body))
post_save.connect(message_sent_handler, sender=Message)

Просмотреть файл

@ -6,6 +6,7 @@ from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.signals import post_save
from django.utils.translation import ugettext as _
from django.template.loader import render_to_string
from drumbeat.models import ModelBase
from activity.models import Activity
@ -57,23 +58,35 @@ def follow_handler(sender, **kwargs):
rel = kwargs.get('instance', None)
if not isinstance(rel, Relationship):
return
user_subject = _("%(name)s is following you on Drumbeat!" % {
'name': rel.source.name,
})
project_subject = _("%(name)s is following your project on Drumbeat!" % {
'name': rel.source.name,
})
activity = Activity(actor=rel.source,
verb='http://activitystrea.ms/schema/1.0/follow')
subject = _(u"%(name)s is now following")
if rel.target_user:
activity.target_user = rel.target_user
user = rel.target_user
pref_key = 'no_email_new_follower'
subject = user_subject
else:
activity.project = rel.target_project
user = rel.target_project.created_by
pref_key = 'no_email_new_project_follower'
subject = project_subject
activity.save()
preferences = AccountPreferences.objects.filter(user=user)
for pref in preferences:
if pref.value and pref.key == pref_key:
return
subject = "New Follower" # todo - write copy
body = ""
body = render_to_string("relationships/emails/new_follower.txt", {
'user': rel.source,
'project': rel.target_project,
})
SendUserEmail.apply_async((user, subject, body))
post_save.connect(follow_handler, sender=Relationship)

Просмотреть файл

@ -173,6 +173,7 @@ CACHE_COUNT_TIMEOUT = 60
# Email goes to the console by default. s/console/smtp/ for regular delivery
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEFAULT_FROM_EMAIL = 'Mozilla Drumbeat <drumbeat@mozilla.org>'
# Copy these to your settings_local.py
RECAPTCHA_PUBLIC_KEY = ''

Просмотреть файл

@ -0,0 +1,8 @@
You have received a new direct message from {{sender}}:
{{ message }}
Reply: http://www.drumbeat.org{{ reply_url }}
Sincerely,
The Drumbeat Team

Просмотреть файл

@ -0,0 +1,7 @@
{{ user.name }} is now following {% if project %}your project{% else %}you{% endif %} on Drumbeat.org!
You can see their profile here:
http://www.drumbeat.org{{ user.get_absolute_url }}
Sincerely,
The Drumbeat Team