||4 months ago|
|djangoldp_notification||4 months ago|
|.gitignore||8 months ago|
|.gitlab-ci.yml||8 months ago|
|MANIFEST.in||1 year ago|
|README.md||9 months ago|
|setup.cfg||6 months ago|
|setup.py||2 years ago|
This module is an add-on for Django REST Framework, based on Django LDP add-on. It serves django models for a notifications component, respecting the Linked Data Platform convention. It aims at enabling people with little development skills to serve their own data, to be used with a LDP application.
An object representing a notification. A notification has the following fields:
||User targeted by the notification.|
||ID of the user at the origin of the notification|
||ID of the object which is the subject of the notification|
||Short description of the notification|
||Longer description of the notification|
||Date of the notification|
||Indicates that the notification has not been read yet.|
NB: You can access to all the notifications of a User at
An object allowing a User to be notified of any change on a resource or a container. A subscription has the following fields:
||ID of the resource or the container to watch|
||ID of the inbox to notify when the resource or the container change|
||(optional) if set, then object['field'] will be sent in the notification, not object|
For convenience, when you create a subscription on an object, DjangoLDP-Notification will parse the object for any one-to-many nested field relations. It will then create nested-subscriptions, i.e. a subscription on the nested field which sends an update to the same inbox, passing the parent model. If this behaviour is undesired you can delete the
You can automatically create required subscriptions based on your settings.py with this management command:
There is a
CurrentUserMiddleware that catches the connected user of the last performed HTTP request and adds
to every model before it is saved. This is useful if you need to get the connected user that performed
the last HTTP request in a
pre_saved signal. You can get it by using the following line :
getattr(instance, MODEL_MODIFICATION_USER_FIELD, "Unknown user")
MODEL_MODIFICATION_USER_FIELD is a constant that lies in
instance is the instance of your model before save in DB.
Create notification on subscribed objects
When an object is saved, a notification is created for all the subscriptions related to this object.
Send email when new notification
When a notification is created, an email is sent to the user.
This package also bring a few Django managment command. You can use them at the root of your SIB project.
This lets you create mocked notifications. Useful for develpment.
python3 manage.py mock_notification [--size <number_of_notifications>]
Will create the number of dummy notifications specified by
By default, 0.
Will suppress old notification. This is a maintenance command to prevent the server to blow under the weight of your notifications.
python3 manage.py suppress_old_notifications [--older <time_period>]
This will erase notification older than the time period specified by
--older. By default, 72h ago.
time_period is expressed in minutes.
m suffix are also valid to express periods in days,
hours and minutes.
# Default. Will delete notifications older than 72h python3 manage.py mock_notification # Default. Will delete notifications older than 10 minutes ago python3 manage.py mock_notification --older 10 # Default. Will delete notifications older than 10 days ago python3 manage.py mock_notification --older 10d # Default. Will delete notifications older than 10 hours ago python3 manage.py mock_notification --older 10h
Check your datas integrity
Because of the way the DjangoLDP's federation work, you may want to send your notification to every subscribers sometimes.
Follow the check_integrity command of DjangoLDP to get how much resources will be impacted:
Then run this command to send notifications:
./manage.py check_integrity --send-subscription-notifications
Notice that you may have to restart your ActivityQueue or your DjangoLDP server, depending on how you configured the ActivityQueueService