app/soc/logic/helper/notifications.py
changeset 1648 11c74138c56d
parent 1563 1d3db748990a
child 1887 8b71f4e58f39
equal deleted inserted replaced
1647:8bbe06730867 1648:11c74138c56d
    22   ]
    22   ]
    23 
    23 
    24 
    24 
    25 import os
    25 import os
    26 import time
    26 import time
    27 
       
    28 from google.appengine.api import users
       
    29 
    27 
    30 from django.template import loader
    28 from django.template import loader
    31 from django.utils.encoding import force_unicode
    29 from django.utils.encoding import force_unicode
    32 from django.utils.translation import ugettext
    30 from django.utils.translation import ugettext
    33 
    31 
    51 DEF_NEW_GROUP_MSG_FMT = ugettext(
    49 DEF_NEW_GROUP_MSG_FMT = ugettext(
    52     "Your %(application_type)s for %(group_name)s has been accepted.")
    50     "Your %(application_type)s for %(group_name)s has been accepted.")
    53 
    51 
    54 DEF_WELCOME_MSG_FMT = ugettext("Welcome to %(site_name)s, %(name)s,")
    52 DEF_WELCOME_MSG_FMT = ugettext("Welcome to %(site_name)s, %(name)s,")
    55 
    53 
    56 DEF_GROUP_INVITE_NOTIFICATION_TEMPLATE = 'soc/notification/messages/invitation.html'
    54 DEF_GROUP_INVITE_NOTIFICATION_TEMPLATE = 'soc/notification/messages/' \
       
    55     'invitation.html'
    57 
    56 
    58 DEF_NEW_GROUP_TEMPLATE = 'soc/group/messages/accepted.html'
    57 DEF_NEW_GROUP_TEMPLATE = 'soc/group/messages/accepted.html'
    59 
    58 
    60 
    59 
    61 def sendInviteNotification(entity):
    60 def sendInviteNotification(entity):
   162   """Sends an email to a user about a new notification.
   161   """Sends an email to a user about a new notification.
   163 
   162 
   164     Args:
   163     Args:
   165       notification_entity: Notification about which the message should be sent
   164       notification_entity: Notification about which the message should be sent
   166   """
   165   """
   167 
       
   168   # get user logic
       
   169   user_logic = model_logic.user
       
   170 
       
   171   # get the current user
       
   172   current_user_entity = user_logic.logic.getForCurrentAccount()
       
   173 
   166 
   174   # create the url to show this notification
   167   # create the url to show this notification
   175   notification_url = "http://%(host)s%(index)s" % {
   168   notification_url = "http://%(host)s%(index)s" % {
   176       'host' : os.environ['HTTP_HOST'],
   169       'host' : os.environ['HTTP_HOST'],
   177       'index': redirects.getPublicRedirect(notification_entity,
   170       'index': redirects.getPublicRedirect(notification_entity,