Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp-notification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp-notification
Commits
f278f759
Verified
Commit
f278f759
authored
5 years ago
by
Jean-Baptiste Pasquier
Browse files
Options
Downloads
Patches
Plain Diff
update: fix
!8
parent
9ad830db
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#1650
passed
5 years ago
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp_notification/models.py
+27
-17
27 additions, 17 deletions
djangoldp_notification/models.py
djangoldp_notification/templates/email.html
+1
-1
1 addition, 1 deletion
djangoldp_notification/templates/email.html
with
28 additions
and
18 deletions
djangoldp_notification/models.py
+
27
−
17
View file @
f278f759
...
@@ -79,22 +79,32 @@ def send_request(target, object_iri):
...
@@ -79,22 +79,32 @@ def send_request(target, object_iri):
@receiver
(
post_save
,
sender
=
Notification
)
@receiver
(
post_save
,
sender
=
Notification
)
def
send_email_on_notification
(
sender
,
instance
,
created
,
**
kwargs
):
def
send_email_on_notification
(
sender
,
instance
,
created
,
**
kwargs
):
if
created
and
instance
.
summary
and
settings
.
JABBER_DEFAULT_HOST
and
instance
.
user
.
email
:
if
created
and
instance
.
summary
and
settings
.
JABBER_DEFAULT_HOST
and
instance
.
user
.
email
:
html_message
=
loader
.
render_to_string
(
try
:
'
email.html
'
,
who
=
requests
.
get
(
instance
.
author
).
json
()[
'
name
'
]
or
'
Unknown Person
'
# I've no idea how to handle dead links.
{
where
=
requests
.
get
(
instance
.
object
).
json
()[
'
name
'
]
or
'
some unknown place
'
# So let's get to the unknown :)
'
on
'
:
settings
.
JABBER_DEFAULT_HOST
,
if
(
instance
.
author
==
instance
.
object
):
'
instance
'
:
instance
,
where
=
"
has sent you a private message
"
'
author
'
:
requests
.
get
(
instance
.
author
).
json
()[
'
name
'
]
or
'
Unknown user
'
else
:
}
where
=
"
mention you on
"
+
where
)
html_message
=
loader
.
render_to_string
(
send_mail
(
'
email.html
'
,
'
Notification on
'
+
settings
.
JABBER_DEFAULT_HOST
,
{
instance
.
summary
,
'
on
'
:
settings
.
JABBER_DEFAULT_HOST
,
settings
.
EMAIL_HOST_USER
or
"
noreply@
"
+
settings
.
JABBER_DEFAULT_HOST
,
'
instance
'
:
instance
,
[
instance
.
user
.
email
],
'
author
'
:
who
,
fail_silently
=
True
,
'
object
'
:
where
html_message
=
html_message
}
)
)
send_mail
(
'
Notification on
'
+
settings
.
JABBER_DEFAULT_HOST
,
instance
.
summary
,
settings
.
EMAIL_HOST_USER
or
"
noreply@
"
+
settings
.
JABBER_DEFAULT_HOST
,
[
instance
.
user
.
email
],
fail_silently
=
True
,
html_message
=
html_message
)
except
:
logging
.
error
(
'
Djangoldp_notifications: Can
\'
t mail the user
'
)
else
:
else
:
if
created
:
if
created
:
raise
Exception
(
'
Misconfiguration, missing JABBER_DEFAULT_HOST or
incomplete instance
'
)
raise
Exception
(
'
Djangoldp_notifications:
Misconfiguration, missing JABBER_DEFAULT_HOST or
no mail for user found
'
)
This diff is collapsed.
Click to expand it.
djangoldp_notification/templates/email.html
+
1
−
1
View file @
f278f759
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
</head>
</head>
<body>
<body>
<div>
<div>
<p
style=
'font-style:italic;color:#777'
>
A new {{ instance.type }} from
<b>
{{ author }}
</b>
on {{ on }}
</p>
<p
style=
'font-style:italic;color:#777'
><b>
{{ author }}
</b>
{{ object }} from
on {{ on }}
</p>
<p>
{{ instance.summary }}
</p>
<p>
{{ instance.summary }}
</p>
</div>
</div>
<div
style=
'margin-top:10px;'
>
<div
style=
'margin-top:10px;'
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment