def send_email(self, request):
'''
Sends an email after being successfully added to the database (for user
submitted ingredients only)
'''
if self.user and self.user.email:
translation.activate(self.user.userprofile.notification_language.short_name)
url = request.build_absolute_uri(self.get_absolute_url())
subject = _('Ingredient was successfully added to the general database')
context = {
'ingredient': self.name,
'url': url,
'site': Site.objects.get_current().domain
}
message = render_to_string('ingredient/email_new.tpl', context)
mail.send_mail(subject,
message,
settings.WGER_SETTINGS['EMAIL_FROM'],
[self.user.email],
fail_silently=True)
评论列表
文章目录