Use sites framework to get domain.
--- 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]
)