Name | django-nyt JSON |
Version |
1.4.1
JSON |
| download |
home_page | None |
Summary | A pluggable notification system written for the Django framework. |
upload_time | 2024-08-21 06:31:45 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
alerts
django
notification
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
django-nyt
==========
.. |Build status| image:: https://circleci.com/gh/django-wiki/django-nyt.svg?style=shield
:target: https://app.circleci.com/pipelines/github/django-wiki/django-nyt
.. image:: https://readthedocs.org/projects/django-nyt/badge/?version=latest
:target: https://django-nyt.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://badge.fury.io/py/django-nyt.svg
:target: https://pypi.org/project/django-nyt/
.. image:: https://codecov.io/github/django-wiki/django-nyt/coverage.svg?branch=main
:target: https://app.codecov.io/github/django-wiki/django-nyt?branch=main
Concept
-------
django-nyt is a notification framework for Django. It does this:
.. code:: python
from django_nyt.utils import notify
EVENT_KEY = "my_key"
notify(_("OMG! Something happened"), EVENT_KEY)
All users subscribing to ``"my_key"`` will have a notification created when ``notify()`` is called.
How the notification is handled depends on the user's settings.
If you have emails enabled, subscribers receive a summary of notifications immediately or at an interval of their choice.
Data can be accessed easily from Django models or from the included JSON views.
By using generic object relations, custom URLs, and custom email templates,
you can expand your notification logic to create email messages that both marks the notification as read when clicking a link and at the same time redirects users to a final destination:
.. code:: python
from django_nyt.utils import notify
product = product
EVENT_KEY = "product_is_in_stock"
notify(
_(f"{product.name} is in stock"),
EVENT_KEY,
url=f"/products/{product.id}/",
target_object=product
)
Roadmap
-------
This project makes sense if people start using it and maturing it to their use-cases.
Here are some aspects that aren't covered but are most welcome:
* Support for async
* Support for notifications through django-channels 4+
* Support for HTML emails (and user setting)
Docs
----
https://django-nyt.readthedocs.io/en/latest/
Why should you do this?
-----------------------
Users need a cleverly sifted stream of events that's highly customizable
as well. By using django-nyt, your users can subscribe to global events
or specific events pertaining specific objects.
Instead of inventing your own notification system, use this and you won't have
to design your own models, and you will have a nice guide that goes through
the various steps of implementing notifications for your project.
Let's try to summarize the reasons you want to be using django-nyt:
- Simple API: call ``notify()`` where-ever you want.
- CLI for sending emails (as cron job, daemon or Celery task)
- Support for django-channels and Web Sockets (optional, fallback for JSON-based polling)
- Basic JavaScript / HTML example code
- Multi-lingual
- Individual subscription settings for each type of event, for instance:
- Event type A spawns instant email notifications, but Event B only gets emailed weekly.
- Customizable intervals for which users can receive notifications
- Optional URL for action target for each notification
- Avoid clutter: Notifications don't get repeated, instead a counter is incremented.
This project exists with ``django.contrib.messages`` in mind, to serve a simple,
best-practice, scalable solution for notifications. There are loads of other
notification apps for Django, some focus on integration of specific communication
protocols
What do you need to do?
-----------------------
django-nyt does everything it can to meet as many needs as possible and
have sane defaults.
But you need to do a lot! Firstly, you need to write some JavaScript that will
fetch the latest notifications and display them in some area of the
screen. Upon clicking that icon, the latest notifications are displayed, and
clicking an individual notification will redirect the user through a page
that marks the notification as read.
Something like this:
.. image:: https://raw.githubusercontent.com/django-wiki/django-nyt/master/docs/misc/screenshot_dropdown.png
:alt: Javascript drop-down
JavaScript drop-down: Some examples are provided in the docs, but there
is no real easy way to place this nifty little thing at the top of your
site, you're going to have to work it out on your own.
Other items for your TODO list:
- Provide your users with options to customize their subscriptions and
notification preferences. Create your own ``Form`` inheriting from
``django_nyt.forms.SettingsForm``.
- Customize contents of notification emails by overwriting templates in
``django_nyt/emails/notification_email_message.txt`` and
``django_nyt/emails/notification_email_subject.txt``.
- You can also have separate email templates per notification key.
This includes using glob patterns.
For instance, you can add this in your settings:
.. code-block:: python
NYT_EMAIL_TEMPLATE_NAMES = OrderedDict({
"ADMIN_*": "myapp/notifications/email/admins.txt"
"*": "myapp/notifications/email/default.txt"
})
NYT_EMAIL_TEMPLATE_SUBJECT_NAMES = OrderedDict({
"ADMIN_*": "myapp/notifications/email/admins_subject.txt"
"*": "myapp/notifications/email/default_subject.txt"
})
- Make the mail notification daemon script run either constantly
``python manage.py notifymail --daemon`` or with some interval by invoking
``python manage.py notifymail --cron`` as a cronjob. You can also call it
from a Celery task or similar with ``call_command('notifymail', cron=True)``.
Development / demo project
--------------------------
In your Git fork, run ``pip install -r requirements.txt`` to install the
requirements.
Install pre-commit hooks to verify your commits::
pip install pre-commit
pre-commit install
The folder **test-project/** contains a pre-configured django project and
an SQlite database. Login for django admin is *admin:admin*::
cd test-project
python manage.py runserver
After this, navigate to `http://localhost:8000 <http://localhost:8000>`_
Community
---------
As many django-wiki users are also familiar with Django,
please visit the channel #django-wiki on Libera.
Click here for a web client <https://web.libera.chat/?channel=#django-wiki>`__).
Otherwise, use the `Discussions <https://github.com/django-wiki/django-nyt/discussions>`__ tab on GitHub.
Raw data
{
"_id": null,
"home_page": null,
"name": "django-nyt",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Oscar Cortez <om.cortez.2010@gmail.com>",
"keywords": "alerts, django, notification",
"author": null,
"author_email": "Benjamin Bach <benjamin@overtag.dk>",
"download_url": "https://files.pythonhosted.org/packages/15/8f/b575be76ba4f71ccd193bf0098a1b8df6b72956fa94bd560aa7f98323261/django_nyt-1.4.1.tar.gz",
"platform": null,
"description": "django-nyt\n==========\n\n.. |Build status| image:: https://circleci.com/gh/django-wiki/django-nyt.svg?style=shield\n :target: https://app.circleci.com/pipelines/github/django-wiki/django-nyt\n.. image:: https://readthedocs.org/projects/django-nyt/badge/?version=latest\n :target: https://django-nyt.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n.. image:: https://badge.fury.io/py/django-nyt.svg\n :target: https://pypi.org/project/django-nyt/\n.. image:: https://codecov.io/github/django-wiki/django-nyt/coverage.svg?branch=main\n :target: https://app.codecov.io/github/django-wiki/django-nyt?branch=main\n\nConcept\n-------\n\ndjango-nyt is a notification framework for Django. It does this:\n\n.. code:: python\n\n from django_nyt.utils import notify\n\n EVENT_KEY = \"my_key\"\n notify(_(\"OMG! Something happened\"), EVENT_KEY)\n\nAll users subscribing to ``\"my_key\"`` will have a notification created when ``notify()`` is called.\nHow the notification is handled depends on the user's settings.\n\nIf you have emails enabled, subscribers receive a summary of notifications immediately or at an interval of their choice.\n\nData can be accessed easily from Django models or from the included JSON views.\n\nBy using generic object relations, custom URLs, and custom email templates,\nyou can expand your notification logic to create email messages that both marks the notification as read when clicking a link and at the same time redirects users to a final destination:\n\n.. code:: python\n\n from django_nyt.utils import notify\n\n product = product\n EVENT_KEY = \"product_is_in_stock\"\n notify(\n _(f\"{product.name} is in stock\"),\n EVENT_KEY,\n url=f\"/products/{product.id}/\",\n target_object=product\n )\n\n\nRoadmap\n-------\n\nThis project makes sense if people start using it and maturing it to their use-cases.\n\nHere are some aspects that aren't covered but are most welcome:\n\n* Support for async\n* Support for notifications through django-channels 4+\n* Support for HTML emails (and user setting)\n\nDocs\n----\n\nhttps://django-nyt.readthedocs.io/en/latest/\n\n\nWhy should you do this?\n-----------------------\n\nUsers need a cleverly sifted stream of events that's highly customizable\nas well. By using django-nyt, your users can subscribe to global events\nor specific events pertaining specific objects.\n\nInstead of inventing your own notification system, use this and you won't have\nto design your own models, and you will have a nice guide that goes through\nthe various steps of implementing notifications for your project.\n\nLet's try to summarize the reasons you want to be using django-nyt:\n\n- Simple API: call ``notify()`` where-ever you want.\n- CLI for sending emails (as cron job, daemon or Celery task)\n- Support for django-channels and Web Sockets (optional, fallback for JSON-based polling)\n- Basic JavaScript / HTML example code\n- Multi-lingual\n- Individual subscription settings for each type of event, for instance:\n - Event type A spawns instant email notifications, but Event B only gets emailed weekly.\n- Customizable intervals for which users can receive notifications\n- Optional URL for action target for each notification\n- Avoid clutter: Notifications don't get repeated, instead a counter is incremented.\n\nThis project exists with ``django.contrib.messages`` in mind, to serve a simple,\nbest-practice, scalable solution for notifications. There are loads of other\nnotification apps for Django, some focus on integration of specific communication\nprotocols\n\nWhat do you need to do?\n-----------------------\n\ndjango-nyt does everything it can to meet as many needs as possible and\nhave sane defaults.\n\nBut you need to do a lot! Firstly, you need to write some JavaScript that will\nfetch the latest notifications and display them in some area of the\nscreen. Upon clicking that icon, the latest notifications are displayed, and\nclicking an individual notification will redirect the user through a page\nthat marks the notification as read.\n\nSomething like this:\n\n.. image:: https://raw.githubusercontent.com/django-wiki/django-nyt/master/docs/misc/screenshot_dropdown.png\n :alt: Javascript drop-down\n\nJavaScript drop-down: Some examples are provided in the docs, but there\nis no real easy way to place this nifty little thing at the top of your\nsite, you're going to have to work it out on your own.\n\nOther items for your TODO list:\n\n- Provide your users with options to customize their subscriptions and\n notification preferences. Create your own ``Form`` inheriting from\n ``django_nyt.forms.SettingsForm``.\n- Customize contents of notification emails by overwriting templates in\n ``django_nyt/emails/notification_email_message.txt`` and\n ``django_nyt/emails/notification_email_subject.txt``.\n- You can also have separate email templates per notification key.\n This includes using glob patterns.\n For instance, you can add this in your settings:\n\n .. code-block:: python\n\n NYT_EMAIL_TEMPLATE_NAMES = OrderedDict({\n \"ADMIN_*\": \"myapp/notifications/email/admins.txt\"\n \"*\": \"myapp/notifications/email/default.txt\"\n })\n NYT_EMAIL_TEMPLATE_SUBJECT_NAMES = OrderedDict({\n \"ADMIN_*\": \"myapp/notifications/email/admins_subject.txt\"\n \"*\": \"myapp/notifications/email/default_subject.txt\"\n })\n\n- Make the mail notification daemon script run either constantly\n ``python manage.py notifymail --daemon`` or with some interval by invoking\n ``python manage.py notifymail --cron`` as a cronjob. You can also call it\n from a Celery task or similar with ``call_command('notifymail', cron=True)``.\n\n\nDevelopment / demo project\n--------------------------\n\nIn your Git fork, run ``pip install -r requirements.txt`` to install the\nrequirements.\n\nInstall pre-commit hooks to verify your commits::\n\n pip install pre-commit\n pre-commit install\n\nThe folder **test-project/** contains a pre-configured django project and\nan SQlite database. Login for django admin is *admin:admin*::\n\n cd test-project\n python manage.py runserver\n\nAfter this, navigate to `http://localhost:8000 <http://localhost:8000>`_\n\n\nCommunity\n---------\n\nAs many django-wiki users are also familiar with Django,\nplease visit the channel #django-wiki on Libera.\nClick here for a web client <https://web.libera.chat/?channel=#django-wiki>`__).\n\nOtherwise, use the `Discussions <https://github.com/django-wiki/django-nyt/discussions>`__ tab on GitHub.\n",
"bugtrack_url": null,
"license": null,
"summary": "A pluggable notification system written for the Django framework.",
"version": "1.4.1",
"project_urls": {
"Documentation": "https://django-nyt.readthedocs.io/en/latest/",
"Funding": "https://donate.pypi.org",
"Homepage": "https://github.com/django-wiki/django-nyt",
"Release notes": "https://github.com/django-wiki/django-nyt/releases",
"Source": "https://github.com/django-wiki/django-nyt",
"Tracker": "https://github.com/django-wiki/django-nyt/issues"
},
"split_keywords": [
"alerts",
" django",
" notification"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "26262eba2be87e823b764634612ac747ae4483b4b66aaba2e825a6297a04da54",
"md5": "cc32d761cb7e5804940b8c84b4358f56",
"sha256": "1b3f72fabe663c0ceef395e0d018624b980949a347cdb2cc10e7c4f2fecd6aff"
},
"downloads": -1,
"filename": "django_nyt-1.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cc32d761cb7e5804940b8c84b4358f56",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 41084,
"upload_time": "2024-08-21T06:31:43",
"upload_time_iso_8601": "2024-08-21T06:31:43.951871Z",
"url": "https://files.pythonhosted.org/packages/26/26/2eba2be87e823b764634612ac747ae4483b4b66aaba2e825a6297a04da54/django_nyt-1.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "158fb575be76ba4f71ccd193bf0098a1b8df6b72956fa94bd560aa7f98323261",
"md5": "14aab5814a6685fb8aed69fca1b77451",
"sha256": "47660e56509c9e0fd21c2e590b4fb7a78ebd903b1d987ee81bf6a0ac3352b4a1"
},
"downloads": -1,
"filename": "django_nyt-1.4.1.tar.gz",
"has_sig": false,
"md5_digest": "14aab5814a6685fb8aed69fca1b77451",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 28960,
"upload_time": "2024-08-21T06:31:45",
"upload_time_iso_8601": "2024-08-21T06:31:45.439189Z",
"url": "https://files.pythonhosted.org/packages/15/8f/b575be76ba4f71ccd193bf0098a1b8df6b72956fa94bd560aa7f98323261/django_nyt-1.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-21 06:31:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "django-wiki",
"github_project": "django-nyt",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"circle": true,
"lcname": "django-nyt"
}