Skip to content

Commit

Permalink
added SITE_NAME and CONTACT_EMAIL to context when rendering join invi…
Browse files Browse the repository at this point in the history
…tation subject and message templates.
  • Loading branch information
brosner committed Aug 27, 2009
1 parent d61cf56 commit dbb3bf7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions friends/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,22 @@ def send_invitation(self, from_user, to_email, message):
contact, created = Contact.objects.get_or_create(email=to_email, user=from_user)
salt = sha_constructor(str(random())).hexdigest()[:5]
confirmation_key = sha_constructor(salt + to_email).hexdigest()

accept_url = u"http://%s%s" % (
unicode(Site.objects.get_current()),
reverse("friends_accept_join", args=(confirmation_key,)),
)

subject = render_to_string("friends/join_invite_subject.txt")
email_message = render_to_string("friends/join_invite_message.txt", {
ctx = {
"SITE_NAME": settings.SITE_NAME,
"CONTACT_EMAIL": settings.CONTACT_EMAIL,
"user": from_user,
"message": message,
"accept_url": accept_url,
})
}

subject = render_to_string("friends/join_invite_subject.txt", ctx)
email_message = render_to_string("friends/join_invite_message.txt", ctx)

send_mail(subject, email_message, settings.DEFAULT_FROM_EMAIL, [to_email])
return self.create(from_user=from_user, contact=contact, message=message, status="2", confirmation_key=confirmation_key)
Expand Down

0 comments on commit dbb3bf7

Please sign in to comment.