%global _empty_manifest_terminate_build 0 Name: python-dj-whisperer Version: 0.2.13 Release: 1 Summary: Stay informed of it License: MIT URL: https://bitbucket.org/akinonteam/dj-whisperer Source0: https://mirrors.nju.edu.cn/pypi/web/packages/de/fa/f9abf65a118b530484dafa19f5be383b3724885e55c60139620bcf974dd6/dj-whisperer-0.2.13.tar.gz BuildArch: noarch %description # Django Whisperer [![Build status](https://img.shields.io/bitbucket/pipelines/akinonteam/dj-whisperer)](https://bitbucket.org/akinonteam/dj-whisperer/addon/pipelines/home) [![Documentation status](https://readthedocs.org/projects/dj-whisperer/badge/?version=latest)](https://dj-whisperer.readthedocs.io/en/latest/?badge=latest) ![PyPI](https://img.shields.io/pypi/v/dj-whisperer) ![PyPI - Django version](https://img.shields.io/pypi/djversions/dj-whisperer) ![PyPI - Python version](https://img.shields.io/pypi/pyversions/dj-whisperer) ![PyPI - License](https://img.shields.io/pypi/l/dj-whisperer) Whisperer informs subscribed users via an URL when a specific event occurs. ## Installation Installation using pip: ``` pip install dj-whisperer ``` `whisperer` package has to be added to `INSTALLED_APPS` and `migrate` command has to be run. ```python INSTALLED_APPS = ( # other apps here... 'whisperer', ) ``` ## Sample Scenario Let's give an example using `Package` model. When an event occurs related to a package, subscribed users are gonna be informed. To do so, firstly which events to subscribe must be determined. In order to learn when a package created: ```python from django.db.models.signals import post_save from whisperer.events import WhispererEvent, registry from whisperer.tasks import deliver_event class PackageCreateEvent(WhispererEvent): serializer_class = PackageSerializer event_type = 'package-created' registry.register(PackageCreateEvent) def signal_receiver(instance, created=False, **kwargs): if created: deliver_event(instance, 'package-created') post_save.connect(signal_receiver, Package) ``` When database transaction succeeds, in short when `transaction.on_commit()`, `deliver_event` must be triggered. Subscribed users now can be informed that a package created if they have created a `Webhook`. ```python import requests requests.post( url='https://your-app.com/whisperer/hooks/', headers={ 'Authorization': 'Token ', }, json={ 'event_type': 'package-created', 'secret_key': 'secret', 'target_url': 'https://example.com/', } ) ``` When a package created, `uuid`, `type` & `data` passed through `PackageSerializer` will be posted to https://example.com/. ```python import requests requests.post( url='https://example.com/', headers={ 'Content-Type': 'application/json', 'X-Whisperer-Event': 'package-created', }, json={ 'event': { 'type': 'package-created', 'uuid': 'da81e85139824c6187dd1e58a7d3f971', }, 'data': { 'id': 61, 'transfer_id': 49, 'order_number': '248398923123', '.....': '......', } } ) ``` In order to cancel the subscription: ```python import requests requests.delete( url='https://your-app.com/whisperer/hooks//', headers={ 'Authorization': 'Token ', } ) ``` %package -n python3-dj-whisperer Summary: Stay informed of it Provides: python-dj-whisperer BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-dj-whisperer # Django Whisperer [![Build status](https://img.shields.io/bitbucket/pipelines/akinonteam/dj-whisperer)](https://bitbucket.org/akinonteam/dj-whisperer/addon/pipelines/home) [![Documentation status](https://readthedocs.org/projects/dj-whisperer/badge/?version=latest)](https://dj-whisperer.readthedocs.io/en/latest/?badge=latest) ![PyPI](https://img.shields.io/pypi/v/dj-whisperer) ![PyPI - Django version](https://img.shields.io/pypi/djversions/dj-whisperer) ![PyPI - Python version](https://img.shields.io/pypi/pyversions/dj-whisperer) ![PyPI - License](https://img.shields.io/pypi/l/dj-whisperer) Whisperer informs subscribed users via an URL when a specific event occurs. ## Installation Installation using pip: ``` pip install dj-whisperer ``` `whisperer` package has to be added to `INSTALLED_APPS` and `migrate` command has to be run. ```python INSTALLED_APPS = ( # other apps here... 'whisperer', ) ``` ## Sample Scenario Let's give an example using `Package` model. When an event occurs related to a package, subscribed users are gonna be informed. To do so, firstly which events to subscribe must be determined. In order to learn when a package created: ```python from django.db.models.signals import post_save from whisperer.events import WhispererEvent, registry from whisperer.tasks import deliver_event class PackageCreateEvent(WhispererEvent): serializer_class = PackageSerializer event_type = 'package-created' registry.register(PackageCreateEvent) def signal_receiver(instance, created=False, **kwargs): if created: deliver_event(instance, 'package-created') post_save.connect(signal_receiver, Package) ``` When database transaction succeeds, in short when `transaction.on_commit()`, `deliver_event` must be triggered. Subscribed users now can be informed that a package created if they have created a `Webhook`. ```python import requests requests.post( url='https://your-app.com/whisperer/hooks/', headers={ 'Authorization': 'Token ', }, json={ 'event_type': 'package-created', 'secret_key': 'secret', 'target_url': 'https://example.com/', } ) ``` When a package created, `uuid`, `type` & `data` passed through `PackageSerializer` will be posted to https://example.com/. ```python import requests requests.post( url='https://example.com/', headers={ 'Content-Type': 'application/json', 'X-Whisperer-Event': 'package-created', }, json={ 'event': { 'type': 'package-created', 'uuid': 'da81e85139824c6187dd1e58a7d3f971', }, 'data': { 'id': 61, 'transfer_id': 49, 'order_number': '248398923123', '.....': '......', } } ) ``` In order to cancel the subscription: ```python import requests requests.delete( url='https://your-app.com/whisperer/hooks//', headers={ 'Authorization': 'Token ', } ) ``` %package help Summary: Development documents and examples for dj-whisperer Provides: python3-dj-whisperer-doc %description help # Django Whisperer [![Build status](https://img.shields.io/bitbucket/pipelines/akinonteam/dj-whisperer)](https://bitbucket.org/akinonteam/dj-whisperer/addon/pipelines/home) [![Documentation status](https://readthedocs.org/projects/dj-whisperer/badge/?version=latest)](https://dj-whisperer.readthedocs.io/en/latest/?badge=latest) ![PyPI](https://img.shields.io/pypi/v/dj-whisperer) ![PyPI - Django version](https://img.shields.io/pypi/djversions/dj-whisperer) ![PyPI - Python version](https://img.shields.io/pypi/pyversions/dj-whisperer) ![PyPI - License](https://img.shields.io/pypi/l/dj-whisperer) Whisperer informs subscribed users via an URL when a specific event occurs. ## Installation Installation using pip: ``` pip install dj-whisperer ``` `whisperer` package has to be added to `INSTALLED_APPS` and `migrate` command has to be run. ```python INSTALLED_APPS = ( # other apps here... 'whisperer', ) ``` ## Sample Scenario Let's give an example using `Package` model. When an event occurs related to a package, subscribed users are gonna be informed. To do so, firstly which events to subscribe must be determined. In order to learn when a package created: ```python from django.db.models.signals import post_save from whisperer.events import WhispererEvent, registry from whisperer.tasks import deliver_event class PackageCreateEvent(WhispererEvent): serializer_class = PackageSerializer event_type = 'package-created' registry.register(PackageCreateEvent) def signal_receiver(instance, created=False, **kwargs): if created: deliver_event(instance, 'package-created') post_save.connect(signal_receiver, Package) ``` When database transaction succeeds, in short when `transaction.on_commit()`, `deliver_event` must be triggered. Subscribed users now can be informed that a package created if they have created a `Webhook`. ```python import requests requests.post( url='https://your-app.com/whisperer/hooks/', headers={ 'Authorization': 'Token ', }, json={ 'event_type': 'package-created', 'secret_key': 'secret', 'target_url': 'https://example.com/', } ) ``` When a package created, `uuid`, `type` & `data` passed through `PackageSerializer` will be posted to https://example.com/. ```python import requests requests.post( url='https://example.com/', headers={ 'Content-Type': 'application/json', 'X-Whisperer-Event': 'package-created', }, json={ 'event': { 'type': 'package-created', 'uuid': 'da81e85139824c6187dd1e58a7d3f971', }, 'data': { 'id': 61, 'transfer_id': 49, 'order_number': '248398923123', '.....': '......', } } ) ``` In order to cancel the subscription: ```python import requests requests.delete( url='https://your-app.com/whisperer/hooks//', headers={ 'Authorization': 'Token ', } ) ``` %prep %autosetup -n dj-whisperer-0.2.13 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-dj-whisperer -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri May 05 2023 Python_Bot - 0.2.13-1 - Package Spec generated