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