Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
lino-framework
lino
Commits
762d3e49
Commit
762d3e49
authored
Jan 06, 2017
by
Luc Saffre
Browse files
notification message in language of recipient
parent
52da1272
Changes
3
Hide whitespace changes
Inline
Side-by-side
lino/modlib/notify/actions.py
View file @
762d3e49
...
...
@@ -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
)
...
...
lino/modlib/notify/mixins.py
View file @
762d3e49
...
...
@@ -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
...
...
lino/modlib/notify/models.py
View file @
762d3e49
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment