79 |
79 |
logger.error(e.message)
|
80 |
80 |
|
81 |
81 |
|
82 |
|
def membership_request_notify(project, requested_user):
|
83 |
|
try:
|
84 |
|
notification = build_notification(
|
85 |
|
SENDER,
|
86 |
|
[project.application.owner.email],
|
87 |
|
_(messages.PROJECT_MEMBERSHIP_REQUEST_SUBJECT) % project.__dict__,
|
88 |
|
template='im/projects/project_membership_request_notification.txt',
|
89 |
|
dictionary={'object': project, 'user': requested_user.email})
|
90 |
|
notification.send()
|
91 |
|
except NotificationError, e:
|
92 |
|
logger.error(e.message)
|
|
82 |
MEMBERSHIP_REQUEST_DATA = {
|
|
83 |
"join": lambda p: (
|
|
84 |
_(messages.PROJECT_MEMBERSHIP_REQUEST_SUBJECT) % p.__dict__,
|
|
85 |
"im/projects/project_membership_request_notification.txt"),
|
|
86 |
"leave": lambda p: (
|
|
87 |
_(messages.PROJECT_MEMBERSHIP_LEAVE_REQUEST_SUBJECT) % p.__dict__,
|
|
88 |
"im/projects/project_membership_leave_request_notification.txt"),
|
|
89 |
}
|
93 |
90 |
|
94 |
91 |
|
95 |
|
def membership_leave_request_notify(project, requested_user):
|
96 |
|
template = 'im/projects/project_membership_leave_request_notification.txt'
|
|
92 |
def membership_request_notify(project, requested_user, action):
|
|
93 |
subject, template = MEMBERSHIP_REQUEST_DATA[action](project)
|
97 |
94 |
try:
|
98 |
|
notification = build_notification(
|
99 |
|
SENDER,
|
100 |
|
[project.application.owner.email],
|
101 |
|
_(messages.PROJECT_MEMBERSHIP_LEAVE_REQUEST_SUBJECT) %
|
102 |
|
project.__dict__,
|
|
95 |
build_notification(
|
|
96 |
SENDER, [project.application.owner.email], subject,
|
103 |
97 |
template=template,
|
104 |
|
dictionary={'object': project, 'user': requested_user.email})
|
105 |
|
notification.send()
|
106 |
|
except NotificationError, e:
|
107 |
|
logger.error(e.message)
|
108 |
|
|
109 |
|
|
110 |
|
def application_submit_notify(application):
|
111 |
|
try:
|
112 |
|
notification = build_notification(
|
113 |
|
SENDER, NOTIFY_RECIPIENTS,
|
114 |
|
_(messages.PROJECT_CREATION_SUBJECT) % application.__dict__,
|
115 |
|
template='im/projects/project_creation_notification.txt',
|
116 |
|
dictionary={'object': application})
|
117 |
|
notification.send()
|
118 |
|
except NotificationError, e:
|
119 |
|
logger.error(e.message)
|
120 |
|
|
121 |
|
|
122 |
|
def application_deny_notify(application):
|
123 |
|
try:
|
124 |
|
notification = build_notification(
|
125 |
|
SENDER,
|
126 |
|
[application.owner.email],
|
127 |
|
_(messages.PROJECT_DENIED_SUBJECT) % application.__dict__,
|
128 |
|
template='im/projects/project_denial_notification.txt',
|
129 |
|
dictionary={'object': application})
|
130 |
|
notification.send()
|
131 |
|
except NotificationError, e:
|
132 |
|
logger.error(e.message)
|
133 |
|
|
134 |
|
|
135 |
|
def application_approve_notify(application):
|
136 |
|
try:
|
137 |
|
notification = build_notification(
|
138 |
|
SENDER,
|
139 |
|
[application.owner.email],
|
140 |
|
_(messages.PROJECT_APPROVED_SUBJECT) % application.__dict__,
|
141 |
|
template='im/projects/project_approval_notification.txt',
|
142 |
|
dictionary={'object': application})
|
143 |
|
notification.send()
|
|
98 |
dictionary={'object': project, 'user': requested_user.email}
|
|
99 |
).send()
|
144 |
100 |
except NotificationError, e:
|
145 |
101 |
logger.error(e.message)
|
146 |
102 |
|
147 |
103 |
|
148 |
|
def project_termination_notify(project):
|
149 |
|
app = project.application
|
150 |
|
try:
|
151 |
|
build_notification(
|
152 |
|
SENDER,
|
153 |
|
[project.application.owner.email],
|
154 |
|
_(messages.PROJECT_TERMINATION_SUBJECT) % app.__dict__,
|
155 |
|
template='im/projects/project_termination_notification.txt',
|
156 |
|
dictionary={'object': project}
|
157 |
|
).send()
|
158 |
|
except NotificationError, e:
|
159 |
|
logger.error(e.message)
|
|
104 |
APPLICATION_DATA = {
|
|
105 |
"submit": lambda a: (
|
|
106 |
NOTIFY_RECIPIENTS,
|
|
107 |
_(messages.PROJECT_CREATION_SUBJECT) % a.__dict__,
|
|
108 |
"im/projects/project_creation_notification.txt"),
|
|
109 |
"deny": lambda a: (
|
|
110 |
[a.owner.email],
|
|
111 |
_(messages.PROJECT_DENIED_SUBJECT) % a.__dict__,
|
|
112 |
"im/projects/project_denial_notification.txt"),
|
|
113 |
"approve": lambda a: (
|
|
114 |
[a.owner.email],
|
|
115 |
_(messages.PROJECT_APPROVED_SUBJECT) % a.__dict__,
|
|
116 |
"im/projects/project_approval_notification.txt"),
|
|
117 |
}
|
160 |
118 |
|
161 |
119 |
|
162 |
|
def project_suspension_notify(project):
|
|
120 |
def application_notify(application, action):
|
|
121 |
recipients, subject, template = APPLICATION_DATA[action](application)
|
163 |
122 |
try:
|
164 |
123 |
build_notification(
|
165 |
|
SENDER,
|
166 |
|
[project.application.owner.email],
|
167 |
|
_(messages.PROJECT_SUSPENSION_SUBJECT) % project.__dict__,
|
168 |
|
template='im/projects/project_suspension_notification.txt',
|
169 |
|
dictionary={'object': project}
|
|
124 |
SENDER, recipients, subject,
|
|
125 |
template=template,
|
|
126 |
dictionary={'object': application}
|
170 |
127 |
).send()
|
171 |
128 |
except NotificationError, e:
|
172 |
129 |
logger.error(e.message)
|
173 |
130 |
|
174 |
131 |
|
175 |
|
def project_unsuspension_notify(project):
|
176 |
|
try:
|
177 |
|
build_notification(
|
178 |
|
SENDER,
|
179 |
|
[project.application.owner.email],
|
180 |
|
_(messages.PROJECT_UNSUSPENSION_SUBJECT) % project.__dict__,
|
181 |
|
template='im/projects/project_unsuspension_notification.txt',
|
182 |
|
dictionary={'object': project}
|
183 |
|
).send()
|
184 |
|
except NotificationError, e:
|
185 |
|
logger.error(e.message)
|
|
132 |
PROJECT_DATA = {
|
|
133 |
"terminate": lambda p: (
|
|
134 |
_(messages.PROJECT_TERMINATION_SUBJECT) % p.application.__dict__,
|
|
135 |
"im/projects/project_termination_notification.txt"),
|
|
136 |
"reinstate": lambda p: (
|
|
137 |
_(messages.PROJECT_REINSTATEMENT_SUBJECT) % p.__dict__,
|
|
138 |
"im/projects/project_reinstatement_notification.txt"),
|
|
139 |
"suspend": lambda p: (
|
|
140 |
_(messages.PROJECT_SUSPENSION_SUBJECT) % p.__dict__,
|
|
141 |
"im/projects/project_suspension_notification.txt"),
|
|
142 |
"unsuspend": lambda p: (
|
|
143 |
_(messages.PROJECT_UNSUSPENSION_SUBJECT) % p.__dict__,
|
|
144 |
"im/projects/project_unsuspension_notification.txt"),
|
|
145 |
}
|
186 |
146 |
|
187 |
147 |
|
188 |
|
def project_reinstatement_notify(project):
|
|
148 |
def project_notify(project, action):
|
|
149 |
subject, template = PROJECT_DATA[action](project)
|
189 |
150 |
try:
|
190 |
151 |
build_notification(
|
191 |
|
SENDER,
|
192 |
|
[project.application.owner.email],
|
193 |
|
_(messages.PROJECT_REINSTATEMENT_SUBJECT) % project.__dict__,
|
194 |
|
template='im/projects/project_reinstatement_notification.txt',
|
|
152 |
SENDER, [project.application.owner.email], subject,
|
|
153 |
template=template,
|
195 |
154 |
dictionary={'object': project}
|
196 |
155 |
).send()
|
197 |
156 |
except NotificationError, e:
|