Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp-notification
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
decentral1se
djangoldp-notification
Commits
5e616fc6
Commit
5e616fc6
authored
4 years ago
by
Calum Mackervoy
Committed by
Jean-Baptiste Pasquier
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feature: notifications pagination
parent
00fd64cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp_notification/models.py
+8
-4
8 additions, 4 deletions
djangoldp_notification/models.py
djangoldp_notification/views.py
+11
-0
11 additions, 0 deletions
djangoldp_notification/views.py
with
19 additions
and
4 deletions
djangoldp_notification/models.py
+
8
−
4
View file @
5e616fc6
...
...
@@ -14,6 +14,7 @@ from djangoldp.models import Model
from
threading
import
Thread
from
djangoldp_notification.middlewares
import
MODEL_MODIFICATION_USER_FIELD
from
djangoldp_notification.permissions
import
InboxPermissions
,
SubscriptionsPermissions
from
djangoldp_notification.views
import
LDPNotifcationsViewSet
class
Notification
(
Model
):
...
...
@@ -32,6 +33,7 @@ class Notification(Model):
anonymous_perms
=
[
'
add
'
]
authenticated_perms
=
[
'
inherit
'
]
owner_perms
=
[
'
view
'
,
'
change
'
,
'
control
'
]
view_set
=
LDPNotifcationsViewSet
def
__str__
(
self
):
return
'
{}
'
.
format
(
self
.
type
)
...
...
@@ -160,7 +162,7 @@ def send_request(target, object_iri, instance, created):
@receiver
(
post_save
,
sender
=
Notification
)
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
getattr
(
settings
,
'
JABBER_DEFAULT_HOST
'
,
False
)
and
instance
.
user
.
email
:
# get author name, and store in who
try
:
# local author
...
...
@@ -186,10 +188,12 @@ def send_email_on_notification(sender, instance, created, **kwargs):
else
:
where
=
"
t
'
a mentionné sur
"
+
where
on
=
(
getattr
(
settings
,
'
INSTANCE_DEFAULT_CLIENT
'
,
False
)
or
settings
.
JABBER_DEFAULT_HOST
)
html_message
=
loader
.
render_to_string
(
'
email.html
'
,
{
'
on
'
:
(
settings
.
INSTANCE_DEFAULT_CLIENT
or
settings
.
JABBER_DEFAULT_HOST
)
,
'
on
'
:
on
,
'
instance
'
:
instance
,
'
author
'
:
who
,
'
object
'
:
where
...
...
@@ -197,9 +201,9 @@ def send_email_on_notification(sender, instance, created, **kwargs):
)
send_mail
(
'
Notification sur
'
+
(
settings
.
INSTANCE_DEFAULT_CLIENT
or
settings
.
JABBER_DEFAULT_HOST
)
,
'
Notification sur
'
+
on
,
instance
.
summary
,
settings
.
EMAIL_HOST_USER
or
"
noreply@
"
+
settings
.
JABBER_DEFAULT_HOST
,
(
getattr
(
settings
,
'
EMAIL_HOST_USER
'
,
False
)
or
"
noreply@
"
+
settings
.
JABBER_DEFAULT_HOST
)
,
[
instance
.
user
.
email
],
fail_silently
=
True
,
html_message
=
html_message
...
...
This diff is collapsed.
Click to expand it.
djangoldp_notification/views.py
0 → 100644
+
11
−
0
View file @
5e616fc6
from
djangoldp.views
import
LDPViewSet
from
djangoldp.pagination
import
LDPPagination
class
LDPNotificationsPagination
(
LDPPagination
):
default_limit
=
100
class
LDPNotifcationsViewSet
(
LDPViewSet
):
'''
overridden LDPViewSet to force pagination
'''
pagination_class
=
LDPNotificationsPagination
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