# Django user notification
[![Build Status](https://img.shields.io/github/workflow/status/anyidea/django-user-notification/CI/master)](https://github.com/anyidea/django-user-notification/actions?query=workflow%3ACI)
[![GitHub license](https://img.shields.io/github/license/anyidea/django-user-notification)](https://github.com/anyidea/django-user-notification/blob/master/LICENSE)
[![Documentation Status](https://readthedocs.org/projects/django-user-notification/badge/?version=latest)](https://django-user-notification.readthedocs.io/en/latest/?badge=latest)
[![pypi-version](https://img.shields.io/pypi/v/django-user-notification.svg)](https://pypi.python.org/pypi/django-user-notification)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-user-notification)
[![PyPI - Django Version](https://img.shields.io/badge/django-%3E%3D3.1-44B78B)](https://www.djangoproject.com/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
Overview
-----
Django user notification is intended to provide a way to send multiple types of notification messages to django users out of box.
Documentation
-----
on the way...
Requirements
-----
* Python 3.8, 3.9, 3.10
* Django 3.1, 3.2, 4.0, 4.1
Installation
-----
Install using `pip`...
pip install django-user-notification
Add `'tinymce'` and `'notification'` to your `INSTALLED_APPS` setting.
```python
INSTALLED_APPS = [
'django.contrib.admin',
...
'tinymce',
'notification',
]
```
Quick Start
-----
Let's take a look at a quick start of using Django user notification to send notification messages to users.
Run the `notification` migrations using:
python manage.py migrate notification
Add the following to your `settings.py` module:
```python
INSTALLED_APPS = [
... # Make sure to include the default installed apps here.
'tinymce',
'notification',
]
DJANGO_USER_NOTIFICATION = {
"aliyunsms": {
"access_key_id": "Your Access Key ID",
"access_key_secret": "Your Access Key Secret",
"sign_name": "Your Sign Name",
},
"dingtalkchatbot": {
"webhook": "Your Webhook URL",
},
"dingtalkworkmessage": {
"agent_id": "Your App Agent ID",
"app_key": "Your App Key",
"app_secret": "Your App Secret",
},
"dingtalktodotask": {
"app_key": "Your App Key",
"app_secret": "Your App Secret",
},
}
```
Add `tinymce.urls` to `urls.py` for your project:
```python
urlpatterns = [
...
path('tinymce/', include('tinymce.urls')),
...
]
```
Let's send a notification
``` {.python}
from django.contrib.auth import get_user_model
from notification.backends import notify_by_email, notify_by_dingtalk_workmessage
User = get_user_model()
recipient = User.objects.first()
# send a dingtalk work message notification
notify_by_dingtalk_workmessage([recipient], phone_field="phone", title="This is a title", message="A test message")
# send a email notiofication
notify_by_email([recipient], title="This is a title", message="A test message")
```
Send Message With Template
--------------
`django-user-notification` support send notifications with custom template, To
specify a custom message template you can provide the `template_code`
and `context` parameters.
1) Create a template message with code named `TMP01` on django admin
2) Provide the `template_code` and `context` to `send` method:
``` {.python}
...
notify_by_email([recipient], template_code="TMP01", context={"content": "Hello"})
```
Supported backends
-----------------------------
- `DummyNotificationBackend`: send dummy message
- `EmailNotificationBackend`: send email notification.
- `WebsocketNotificationBackend`: send webdocket notification, need install extension: `channels`.
- `AliyunSMSNotificationBackend`: send aliyun sms notification, need install extension: `aliyunsms`.
- `DingTalkChatbotNotificationBackend`: send dingtalk chatbot notification.
- `DingTalkToDoTaskNotificationBackend`: send dingtalk todo tasks notification
- `DingTalkWorkMessageNotificationBackend`: send dingtalk work message notification.
- `WechatNotificationBackend`: planning...
Running the tests
-----------------
To run the tests against the current environment:
``` {.bash}
$ pytest tests/
```
Changelog
---------
### 0.7.0
- Initial release
Contributing
------------
As an open source project, we welcome contributions. The code lives on [GitHub](https://github.com/anyidea/django-user-notification/)
## Thanks
[![PyCharm](docs/pycharm.svg)](https://www.jetbrains.com/?from=django-user-notification)
Raw data
{
"_id": null,
"home_page": "https://github.com/aiden520/django-user-notification",
"name": "django-user-notification",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "notification,django",
"author": "Aiden Lu",
"author_email": "allaher@icloud.com",
"download_url": "https://files.pythonhosted.org/packages/ca/00/5638112a042584feee5b35336a026dad225d92e9e20a221328aa52148edd/django_user_notification-0.10.2.tar.gz",
"platform": null,
"description": "# Django user notification\n\n[![Build Status](https://img.shields.io/github/workflow/status/anyidea/django-user-notification/CI/master)](https://github.com/anyidea/django-user-notification/actions?query=workflow%3ACI)\n[![GitHub license](https://img.shields.io/github/license/anyidea/django-user-notification)](https://github.com/anyidea/django-user-notification/blob/master/LICENSE)\n[![Documentation Status](https://readthedocs.org/projects/django-user-notification/badge/?version=latest)](https://django-user-notification.readthedocs.io/en/latest/?badge=latest)\n[![pypi-version](https://img.shields.io/pypi/v/django-user-notification.svg)](https://pypi.python.org/pypi/django-user-notification)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-user-notification)\n[![PyPI - Django Version](https://img.shields.io/badge/django-%3E%3D3.1-44B78B)](https://www.djangoproject.com/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nOverview\n-----\nDjango user notification is intended to provide a way to send multiple types of notification messages to django users out of box.\n\nDocumentation\n-----\non the way...\n\nRequirements\n-----\n\n* Python 3.8, 3.9, 3.10\n* Django 3.1, 3.2, 4.0, 4.1\n\nInstallation\n-----\n\nInstall using `pip`...\n\n pip install django-user-notification\n\nAdd `'tinymce'` and `'notification'` to your `INSTALLED_APPS` setting.\n```python\nINSTALLED_APPS = [\n 'django.contrib.admin',\n ...\n 'tinymce',\n 'notification',\n]\n```\n\nQuick Start\n-----\n\nLet's take a look at a quick start of using Django user notification to send notification messages to users.\n\nRun the `notification` migrations using:\n\n python manage.py migrate notification\n\n\nAdd the following to your `settings.py` module:\n\n```python\nINSTALLED_APPS = [\n ... # Make sure to include the default installed apps here.\n 'tinymce',\n 'notification',\n]\n\nDJANGO_USER_NOTIFICATION = {\n \"aliyunsms\": {\n \"access_key_id\": \"Your Access Key ID\",\n \"access_key_secret\": \"Your Access Key Secret\",\n \"sign_name\": \"Your Sign Name\",\n },\n \"dingtalkchatbot\": {\n \"webhook\": \"Your Webhook URL\",\n },\n \"dingtalkworkmessage\": {\n \"agent_id\": \"Your App Agent ID\",\n \"app_key\": \"Your App Key\",\n \"app_secret\": \"Your App Secret\",\n },\n \"dingtalktodotask\": {\n \"app_key\": \"Your App Key\",\n \"app_secret\": \"Your App Secret\",\n },\n}\n```\n\nAdd `tinymce.urls` to `urls.py` for your project:\n```python\nurlpatterns = [\n ...\n path('tinymce/', include('tinymce.urls')),\n ...\n]\n```\n\nLet's send a notification\n\n``` {.python}\nfrom django.contrib.auth import get_user_model\nfrom notification.backends import notify_by_email, notify_by_dingtalk_workmessage\n\nUser = get_user_model()\n\nrecipient = User.objects.first()\n\n# send a dingtalk work message notification\nnotify_by_dingtalk_workmessage([recipient], phone_field=\"phone\", title=\"This is a title\", message=\"A test message\")\n\n\n# send a email notiofication\nnotify_by_email([recipient], title=\"This is a title\", message=\"A test message\")\n```\n\n\nSend Message With Template\n--------------\n\n`django-user-notification` support send notifications with custom template, To\nspecify a custom message template you can provide the `template_code`\nand `context` parameters.\n\n1) Create a template message with code named `TMP01` on django admin\n\n2) Provide the `template_code` and `context` to `send` method:\n``` {.python}\n...\n\nnotify_by_email([recipient], template_code=\"TMP01\", context={\"content\": \"Hello\"})\n```\n\nSupported backends\n-----------------------------\n\n- `DummyNotificationBackend`: send dummy message\n- `EmailNotificationBackend`: send email notification.\n- `WebsocketNotificationBackend`: send webdocket notification, need install extension: `channels`.\n- `AliyunSMSNotificationBackend`: send aliyun sms notification, need install extension: `aliyunsms`.\n- `DingTalkChatbotNotificationBackend`: send dingtalk chatbot notification.\n- `DingTalkToDoTaskNotificationBackend`: send dingtalk todo tasks notification\n- `DingTalkWorkMessageNotificationBackend`: send dingtalk work message notification.\n- `WechatNotificationBackend`: planning...\n\nRunning the tests\n-----------------\n\nTo run the tests against the current environment:\n\n``` {.bash}\n$ pytest tests/\n```\n\nChangelog\n---------\n\n### 0.7.0\n\n- Initial release\n\nContributing\n------------\nAs an open source project, we welcome contributions. The code lives on [GitHub](https://github.com/anyidea/django-user-notification/)\n\n## Thanks\n\n[![PyCharm](docs/pycharm.svg)](https://www.jetbrains.com/?from=django-user-notification)\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Django message notification package",
"version": "0.10.2",
"project_urls": {
"Homepage": "https://github.com/aiden520/django-user-notification",
"Repository": "https://github.com/aiden520/django-user-notification"
},
"split_keywords": [
"notification",
"django"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "370f9d8b59b6bbd649f0b55c58ad2e7657c7cc61427d081b23b234e971c200ad",
"md5": "a818be81cb4785c31591857df48ef328",
"sha256": "79621f0da6a6e37e5e3c733310cafeec74d906cfe22979ef8b8c507a6755cd19"
},
"downloads": -1,
"filename": "django_user_notification-0.10.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a818be81cb4785c31591857df48ef328",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 30899,
"upload_time": "2023-07-24T01:44:53",
"upload_time_iso_8601": "2023-07-24T01:44:53.184631Z",
"url": "https://files.pythonhosted.org/packages/37/0f/9d8b59b6bbd649f0b55c58ad2e7657c7cc61427d081b23b234e971c200ad/django_user_notification-0.10.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ca005638112a042584feee5b35336a026dad225d92e9e20a221328aa52148edd",
"md5": "613923f5ee4451bd69aa06369d5e4771",
"sha256": "30dc84011a5b261f1f4da983bef53c87ace0f83e0f5e920d6c4fec477e7c2805"
},
"downloads": -1,
"filename": "django_user_notification-0.10.2.tar.gz",
"has_sig": false,
"md5_digest": "613923f5ee4451bd69aa06369d5e4771",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 19037,
"upload_time": "2023-07-24T01:44:55",
"upload_time_iso_8601": "2023-07-24T01:44:55.095046Z",
"url": "https://files.pythonhosted.org/packages/ca/00/5638112a042584feee5b35336a026dad225d92e9e20a221328aa52148edd/django_user_notification-0.10.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-24 01:44:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aiden520",
"github_project": "django-user-notification",
"github_not_found": true,
"lcname": "django-user-notification"
}