app/soc/logic/helper/notifications.py
changeset 1548 15caebd3304d
parent 1546 cc54ada3cf1b
child 1550 a872030dc3ca
equal deleted inserted replaced
1547:c8c269ef0498 1548:15caebd3304d
    31 from django.utils.encoding import force_unicode
    31 from django.utils.encoding import force_unicode
    32 from django.utils.translation import ugettext
    32 from django.utils.translation import ugettext
    33 
    33 
    34 # We cannot import soc.logic.models notification nor user here
    34 # We cannot import soc.logic.models notification nor user here
    35 # due to cyclic imports
    35 # due to cyclic imports
       
    36 from soc.logic import accounts
    36 from soc.logic import dicts
    37 from soc.logic import dicts
    37 from soc.logic import mail_dispatcher
    38 from soc.logic import mail_dispatcher
    38 from soc.views.helper import redirects
    39 from soc.views.helper import redirects
    39 
    40 
    40 import soc.views.models as model_view
    41 import soc.views.models as model_view
   180 
   181 
   181   if not sender:
   182   if not sender:
   182     # no valid sender found, abort
   183     # no valid sender found, abort
   183     return
   184     return
   184 
   185 
       
   186   to = accounts.denormalizeAccount(notification_entity.scope.account).email()
       
   187 
   185   # create the message contents
   188   # create the message contents
   186   messageProperties = {
   189   messageProperties = {
   187       'to_name': notification_entity.scope.name,
   190       'to_name': notification_entity.scope.name,
   188       'sender_name': current_user_entity.name,
   191       'sender_name': current_user_entity.name,
   189       'to': notification_entity.scope.account.email(),
   192       'to': to,
   190       'sender': sender,
   193       'sender': sender,
   191       'subject': force_unicode(DEF_NEW_NOTIFICATION_MSG),
   194       'subject': force_unicode(DEF_NEW_NOTIFICATION_MSG),
   192       'notification' : notification_entity,
   195       'notification' : notification_entity,
   193       'notification_url' : notification_url
   196       'notification_url' : notification_url
   194       }
   197       }
   213   sender = mail_dispatcher.getDefaultMailSender()
   216   sender = mail_dispatcher.getDefaultMailSender()
   214 
   217 
   215   if not sender:
   218   if not sender:
   216     # no valid sender found, should not happen but abort anyway
   219     # no valid sender found, should not happen but abort anyway
   217     return
   220     return
       
   221 
       
   222   to = accounts.denormalizeAccount(user_entity.account).email()
   218 
   223 
   219   # create the message contents
   224   # create the message contents
   220   messageProperties = {
   225   messageProperties = {
   221       'to_name': user_entity.name,
   226       'to_name': user_entity.name,
   222       'sender_name': site_name,
   227       'sender_name': site_name,
   223       'site_name': site_name,
   228       'site_name': site_name,
   224       'to': user_entity.account.email(),
   229       'to': to,
   225       'sender': sender,
   230       'sender': sender,
   226       'subject': DEF_WELCOME_MSG_FMT % {
   231       'subject': DEF_WELCOME_MSG_FMT % {
   227           'site_name': site_name,
   232           'site_name': site_name,
   228           'name': user_entity.name
   233           'name': user_entity.name
   229           }
   234           }