equal
deleted
inserted
replaced
20 __authors__ = [ |
20 __authors__ = [ |
21 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
21 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
22 ] |
22 ] |
23 |
23 |
24 |
24 |
25 import os |
|
26 import time |
25 import time |
27 |
26 |
28 from django.template import loader |
27 from django.template import loader |
29 from django.utils.encoding import force_unicode |
28 from django.utils.encoding import force_unicode |
30 from django.utils.translation import ugettext |
29 from django.utils.translation import ugettext |
32 # We cannot import soc.logic.models notification nor user here |
31 # We cannot import soc.logic.models notification nor user here |
33 # due to cyclic imports |
32 # due to cyclic imports |
34 from soc.logic import accounts |
33 from soc.logic import accounts |
35 from soc.logic import dicts |
34 from soc.logic import dicts |
36 from soc.logic import mail_dispatcher |
35 from soc.logic import mail_dispatcher |
|
36 from soc.logic import system |
37 from soc.views.helper import redirects |
37 from soc.views.helper import redirects |
38 |
38 |
39 |
39 |
40 DEF_NEW_NOTIFICATION_MSG = ugettext( |
40 DEF_NEW_NOTIFICATION_MSG = ugettext( |
41 "You have received a new Notification.") |
41 "You have received a new Notification.") |
79 # get the user the request is for |
79 # get the user the request is for |
80 properties = {'link_id': entity.link_id } |
80 properties = {'link_id': entity.link_id } |
81 to_user = user_logic.getForFields(properties, unique=True) |
81 to_user = user_logic.getForFields(properties, unique=True) |
82 |
82 |
83 invitation_url = "http://%(host)s%(index)s" % { |
83 invitation_url = "http://%(host)s%(index)s" % { |
84 'host' : os.environ['HTTP_HOST'], |
84 'host' : system.getHostname(), |
85 'index': redirects.getInviteProcessRedirect(entity, None), |
85 'index': redirects.getInviteProcessRedirect(entity, None), |
86 } |
86 } |
87 |
87 |
88 message_properties = { |
88 message_properties = { |
89 'role_verbose' : entity.role_verbose, |
89 'role_verbose' : entity.role_verbose, |
162 """ |
162 """ |
163 |
163 |
164 url = "http://%(host)s%(redirect)s" % { |
164 url = "http://%(host)s%(redirect)s" % { |
165 'redirect': redirects.getApplicantRedirect(entity, |
165 'redirect': redirects.getApplicantRedirect(entity, |
166 {'url_name': params['group_url_name']}), |
166 {'url_name': params['group_url_name']}), |
167 'host': os.environ['HTTP_HOST'], |
167 'host': system.getHostname(), |
168 } |
168 } |
169 |
169 |
170 message_properties = { |
170 message_properties = { |
171 'application_type': params['name'], |
171 'application_type': params['name'], |
172 'group_type': params['group_name'], |
172 'group_type': params['group_name'], |
267 from soc.logic.models.site import logic as site_logic |
267 from soc.logic.models.site import logic as site_logic |
268 from soc.views.models.notification import view as notification_view |
268 from soc.views.models.notification import view as notification_view |
269 |
269 |
270 # create the url to show this notification |
270 # create the url to show this notification |
271 notification_url = "http://%(host)s%(index)s" % { |
271 notification_url = "http://%(host)s%(index)s" % { |
272 'host' : os.environ['HTTP_HOST'], |
272 'host' : system.getHostname(), |
273 'index': redirects.getPublicRedirect(notification_entity, |
273 'index': redirects.getPublicRedirect(notification_entity, |
274 notification_view.getParams())} |
274 notification_view.getParams())} |
275 |
275 |
276 sender = mail_dispatcher.getDefaultMailSender() |
276 sender = mail_dispatcher.getDefaultMailSender() |
277 site_entity = site_logic.getSingleton() |
277 site_entity = site_logic.getSingleton() |
338 'subject': DEF_WELCOME_MSG_FMT % { |
338 'subject': DEF_WELCOME_MSG_FMT % { |
339 'site_name': site_name, |
339 'site_name': site_name, |
340 'name': user_entity.name |
340 'name': user_entity.name |
341 }, |
341 }, |
342 'site_name': site_name, |
342 'site_name': site_name, |
343 'site_location': 'http://%s' % os.environ['HTTP_HOST'], |
343 'site_location': 'http://%s' % system.getHostname(), |
344 } |
344 } |
345 |
345 |
346 # send out the message using the default welcome template |
346 # send out the message using the default welcome template |
347 mail_dispatcher.sendMailFromTemplate('soc/mail/welcome.html', |
347 mail_dispatcher.sendMailFromTemplate('soc/mail/welcome.html', |
348 messageProperties) |
348 messageProperties) |