# HG changeset patch # User Alexandre Segura # Date 1493811301 -7200 # Node ID 6436836cd043595ac31ff490df980d802ce1765b # Parent 5e8ef87576ec674c677b38b39dce26bfcc8abe54 Use sites framework to get domain. diff -r 5e8ef87576ec -r 6436836cd043 src/iconolab/mails.py --- a/src/iconolab/mails.py Wed May 03 10:40:48 2017 +0200 +++ b/src/iconolab/mails.py Wed May 03 13:35:01 2017 +0200 @@ -1,7 +1,10 @@ from django.conf import settings +from django.contrib.sites.models import Site from django.core.mail import send_mail from django.core.urlresolvers import reverse +current_site = Site.objects.get_current() + class EmailManager(): VERB_NEW_COMMENT = 'a écrit un commentaire sur votre annotation' @@ -11,13 +14,19 @@ VERB_REQUEST_FOR_CONTRIBUTION = 'a fait un appel à contribution' VERB_REQUEST_FOR_EXPERTISE = 'a fait un appel à expertise' - def __message_content(self): - return 'Connectez-vous pour voir les notifications \n\n' + settings.BASE_URL + reverse('user_notifications') + def __message_content(self, verb): + notifications_url = 'http://' + current_site.domain + reverse('user_notifications') + + message = 'Un utilisateur ' + verb + '\n' + message += 'Connectez-vous pour voir les notifications\n\n' + message += notifications_url + + return message def __send_mail(self, recipient, verb): send_mail( 'Un utilisateur ' + verb, - self.__message_content(), + self.__message_content(verb), settings.CONTACT_EMAIL, [recipient.email] )