Commit 762d3e49 authored by Luc Saffre's avatar Luc Saffre
Browse files

notification message in language of recipient

parent 52da1272
......@@ -82,7 +82,8 @@ class NotifyingAction(actions.Action):
recipients = self.get_notify_recipients(ar, obj)
mt = rt.models.notify.MessageTypes.action
pv = ar.action_param_values
msg = pv.notify_subject + "\n" + pv.notify_body
def msg(user, mm):
return pv.notify_subject + "\n" + pv.notify_body
rt.models.notify.Message.emit_message(
ar, owner, mt, msg, recipients)
......
......@@ -73,9 +73,10 @@ class ChangeObservable(dd.Model):
super(ChangeObservable, self).after_ui_save(ar, cw)
msg = self.get_notify_message(ar, cw)
if not msg:
return
def msg(user, mm):
return self.get_notify_message(ar, cw)
# if not msg:
# return
# subject, body = msg
owner = self.get_notify_owner(ar)
mt = rt.actors.notify.MessageTypes.change
......
......@@ -159,10 +159,11 @@ class Message(UserAuthored, Controllable, Created):
# self.user, self.owner)
@classmethod
def emit_message(cls, ar, owner, message_type, body, recipients):
def emit_message(cls, ar, owner, message_type, body_func, recipients):
"""Create one database object for every recipient.
`recipients` is a list of `(user, mail_mode)` tuples.
`body_func` is a callable to be called for each recipient.
The changing user does not get notified about their own
changes, except when working as another user.
......@@ -181,9 +182,12 @@ class Message(UserAuthored, Controllable, Created):
# dd.logger.info(
# "Notify %s users about %s", len(others), subject)
for user, mm in others:
cls.create_message(
user, owner, body=body,
mail_mode=mm, message_type=message_type)
with dd.translation.override(user.language):
body = body_func(user, mm)
if body:
cls.create_message(
user, owner, body=body,
mail_mode=mm, message_type=message_type)
@classmethod
def create_message(cls, user, owner=None, **kwargs):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment