75 pass |
80 pass |
76 |
81 |
77 |
82 |
78 def sendInviteMessage(self, entity): |
83 def sendInviteMessage(self, entity): |
79 """Sends out an invite notification to the user the request is for. |
84 """Sends out an invite notification to the user the request is for. |
80 |
85 |
81 Args: |
86 Args: |
82 entity : A request containing the information needed to create the message |
87 entity : A request containing the information needed to create the message |
83 |
|
84 """ |
88 """ |
|
89 |
85 # get the current user |
90 # get the current user |
86 properties = {'account': users.get_current_user()} |
91 properties = {'account': users.get_current_user()} |
87 current_user_entity = user_logic.logic.getForFields(properties, unique=True) |
92 current_user_entity = user_logic.logic.getForFields(properties, unique=True) |
88 |
93 |
89 # get the user the request is for |
94 # get the user the request is for |
90 properties = {'link_id': entity.link_id } |
95 properties = {'link_id': entity.link_id } |
91 request_user_entity = user_logic.logic.getForFields(properties, unique=True) |
96 request_user_entity = user_logic.logic.getForFields(properties, unique=True) |
92 |
97 |
93 # create the invitation_url |
98 # create the invitation_url |
94 invitation_url = "%(host)s%(index)s" % { |
99 invitation_url = "%(host)s%(index)s" % { |
95 'host' : os.environ['HTTP_HOST'], |
100 'host' : os.environ['HTTP_HOST'], |
96 'index': self.inviteAcceptedRedirect(entity, None) |
101 'index': self.inviteAcceptedRedirect(entity, None) |
97 } |
102 } |
98 |
103 |
99 # get the group entity |
104 # get the group entity |
100 group_entity = entity.scope |
105 group_entity = entity.scope |
101 |
106 |
102 messageProperties = { |
107 messageProperties = { |
103 'to_name': request_user_entity.name, |
108 'to_name': request_user_entity.name, |
104 'sender_name': current_user_entity.name, |
109 'sender_name': current_user_entity.name, |
105 'role': entity.role, |
110 'role': entity.role, |
106 'group': group_entity.name, |
111 'group': group_entity.name, |
107 'invitation_url': invitation_url, |
112 'invitation_url': invitation_url, |
108 'to': request_user_entity.account.email(), |
113 'to': request_user_entity.account.email(), |
109 'sender': current_user_entity.account.email(), |
114 'sender': current_user_entity.account.email(), |
110 'subject': "Invitation to become a %(role)s for %(group)s" |
115 'subject': self.DEF_INVITATION_FMT % { |
111 %{'role': entity.role, 'group': group_entity.name}, |
116 'role': entity.role, |
112 } |
117 'group': group_entity.name |
113 |
118 }, |
|
119 } |
|
120 |
114 # send out the message using the default invitation template |
121 # send out the message using the default invitation template |
115 mail_dispatcher.sendMailFromTemplate('soc/mail/invitation.html', |
122 mail_dispatcher.sendMailFromTemplate('soc/mail/invitation.html', |
116 messageProperties) |
123 messageProperties) |
117 |
124 |
118 def inviteAcceptedRedirect(self, entity, _): |
125 def inviteAcceptedRedirect(self, entity, _): |
119 """Returns the redirect for accepting an invite |
126 """Returns the redirect for accepting an invite |
120 """ |
127 """ |
121 |
128 |
122 return '/%s/create/%s/%s' % ( |
129 return '/%s/create/%s/%s' % ( |