Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
History
=======

not released yet
----------------

* Add ``PYNOTIFY_RECIPIENT_MODEL`` config option

0.4.1 (2020-10-12)
------------------

Expand Down
5 changes: 5 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ You can configure the library in Django settings. Following options are availabl

Import path to a receiver class.

* ``PYNOTIFY_RECIPIENT_MODEL`` (default: ``settings.AUTH_USER_MODEL``)

Model used for recipient's foreign key on ``Notification`` model. Please note, that if you change this setting after
initial migration has been aplied, you might need to migrate the model manually.

* ``PYNOTIFY_RELATED_OBJECTS_ALLOWED_ATTRIBUTES`` (default: ``{'get_absolute_url', }``)

A set of related object's attributes that can be used in notification template(s).
Expand Down
1 change: 1 addition & 0 deletions pynotify/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Settings:
'CELERY_TASK': 'pynotify.tasks.notification_task',
'ENABLED': True,
'RECEIVER': 'pynotify.receivers.SynchronousReceiver',
'RECIPIENT_MODEL': django_settings.AUTH_USER_MODEL,
'RELATED_OBJECTS_ALLOWED_ATTRIBUTES': {'get_absolute_url', },
'STRIP_HTML': False,
'TEMPLATE_CHECK': False,
Expand Down
7 changes: 4 additions & 3 deletions pynotify/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Generated by Django 2.2rc1 on 2019-03-20 11:24

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion

from pynotify.config import settings


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
migrations.swappable_dependency(settings.RECIPIENT_MODEL),
('contenttypes', '0002_remove_content_type_name'),
]

Expand All @@ -24,7 +25,7 @@ class Migration(migrations.Migration):
('is_read', models.BooleanField(default=False, verbose_name='is read')),
('is_triggered', models.BooleanField(default=False, verbose_name='is triggered')),
('recipient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
related_name='notifications', to=settings.AUTH_USER_MODEL,
related_name='notifications', to=settings.RECIPIENT_MODEL,
verbose_name='recipient')),
],
options={
Expand Down
3 changes: 1 addition & 2 deletions pynotify/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re

from chamber.models import SmartModel, SmartModelBase, SmartQuerySet
from django.conf import settings as django_settings
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.core.serializers.json import DjangoJSONEncoder
Expand Down Expand Up @@ -187,7 +186,7 @@ class Notification(BaseModel, metaclass=NotificationMeta):
extra_data: JSON serialized dictionary with extra data.
"""
recipient = models.ForeignKey(
django_settings.AUTH_USER_MODEL,
settings.RECIPIENT_MODEL,
related_name='notifications',
on_delete=models.CASCADE,
verbose_name=_l('recipient'),
Expand Down
8 changes: 5 additions & 3 deletions requirements_docs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
-r requirements_dev.txt
django>=2.2
celery>=4.2.0
django-chamber>=0.5.0
beautifulsoup4==4.*
celery==4.*
django-chamber==0.*
django==2.*
lxml==4.*
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
with open('HISTORY.rst') as history_file:
history = history_file.read()

# keep in sync with requirements_docs.txt
requirements = [
'beautifulsoup4 ~=4.8.0',
'celery >= 4.2.0',
'django >= 2.2',
'django-chamber ~= 0.5.0',
'lxml ~= 4.5.0',
'beautifulsoup4==4.*',
'celery==4.*',
'django==2.*',
'django-chamber==0.*',
'lxml==4.*',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little bit restricted compatibility, but I think it's still OK.

]

setup(
Expand Down