Skip to content

Commit b8af7eb

Browse files
authored
[deps] Added support for Django 4.1.0 and Django 4.2.0
- Dropped support for Python 3.7 - Bumped django-notifications-hq~=1.8.2 - Bumped markdown~=3.4.3 - [ci] Run testsuite with parallel support
1 parent d90bcde commit b8af7eb

File tree

12 files changed

+156
-58
lines changed

12 files changed

+156
-58
lines changed

.coveragerc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ omit =
44
/tests
55
/*/__init__.py
66
/setup.py
7-
/*/migrations/*
7+
/*/migrations/*
8+
source = openwisp_notifications
9+
parallel = true
10+
concurrency = multiprocessing

.github/workflows/build.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,13 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
python-version:
29-
- 3.7
30-
- 3.8
31-
- 3.9
29+
- "3.8"
30+
- "3.9"
31+
- "3.10"
3232
django-version:
33-
- django~=3.0.0
34-
- django~=3.1.0
3533
- django~=3.2.0
36-
include:
37-
- django-version: django~=4.0.0
38-
python-version: 3.9
39-
- django-version: django~=4.0.0
40-
python-version: 3.8
34+
- django~=4.1.0
35+
- django~=4.2.0
4136

4237
steps:
4338
- uses: actions/checkout@v2
@@ -57,14 +52,14 @@ jobs:
5752
- name: Upgrade python system packages
5853
run: pip install -U pip wheel setuptools
5954

60-
- name: Install openwisp-notifications
55+
- name: Install test dependencies
6156
run: |
62-
pip install -e .
57+
pip install -U -r requirements-test.txt
6358
64-
- name: Install test dependencies
59+
- name: Install openwisp-notifications
6560
run: |
61+
pip install -U -e .
6662
pip install ${{ matrix.django-version }}
67-
pip install -U -r requirements-test.txt
6863
6964
- name: Install npm dependencies
7065
run: sudo npm install -g jshint stylelint
@@ -75,8 +70,9 @@ jobs:
7570
7671
- name: Tests
7772
run: |
78-
SAMPLE_APP=1 coverage run --source=openwisp_notifications runtests.py
79-
coverage run -a --source=openwisp_notifications runtests.py
73+
SAMPLE_APP=1 ./runtests.py
74+
coverage run runtests.py --parallel
75+
coverage combine
8076
8177
- name: Upload Coverage
8278
run: coveralls --service=github

openwisp_notifications/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,3 @@ def get_version():
1616
rev = 0
1717
version = '%s%s%s' % (version, VERSION[3][0:1], rev)
1818
return version
19-
20-
21-
default_app_config = 'openwisp_notifications.apps.OpenwispNotificationsConfig'

openwisp_notifications/migrations/0001_initial.py

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,30 +97,74 @@ class Migration(migrations.Migration):
9797
],
9898
default='info',
9999
max_length=20,
100+
verbose_name='level',
100101
),
101102
),
102-
('unread', models.BooleanField(db_index=True, default=True)),
103-
('actor_object_id', models.CharField(max_length=255)),
104-
('verb', models.CharField(max_length=255)),
105-
('description', models.TextField(blank=True, null=True)),
103+
(
104+
'unread',
105+
models.BooleanField(
106+
db_index=True, default=True, verbose_name='unread'
107+
),
108+
),
109+
(
110+
'actor_object_id',
111+
models.CharField(max_length=255, verbose_name='actor object id'),
112+
),
113+
('verb', models.CharField(max_length=255, verbose_name='verb')),
114+
(
115+
'description',
116+
models.TextField(blank=True, null=True, verbose_name='description'),
117+
),
106118
(
107119
'target_object_id',
108-
models.CharField(blank=True, max_length=255, null=True),
120+
models.CharField(
121+
blank=True,
122+
max_length=255,
123+
null=True,
124+
verbose_name='target object id',
125+
),
109126
),
110127
(
111128
'action_object_object_id',
112-
models.CharField(blank=True, max_length=255, null=True),
129+
models.CharField(
130+
blank=True,
131+
max_length=255,
132+
null=True,
133+
verbose_name='action object object id',
134+
),
113135
),
114136
(
115137
'timestamp',
116138
models.DateTimeField(
117-
db_index=True, default=django.utils.timezone.now
139+
db_index=True,
140+
default=django.utils.timezone.now,
141+
verbose_name='timestamp',
142+
),
143+
),
144+
(
145+
'public',
146+
models.BooleanField(
147+
db_index=True, default=True, verbose_name='public'
148+
),
149+
),
150+
(
151+
'deleted',
152+
models.BooleanField(
153+
db_index=True, default=False, verbose_name='deleted'
154+
),
155+
),
156+
(
157+
'emailed',
158+
models.BooleanField(
159+
db_index=True, default=False, verbose_name='emailed'
160+
),
161+
),
162+
(
163+
'data',
164+
jsonfield.fields.JSONField(
165+
blank=True, null=True, verbose_name='data'
118166
),
119167
),
120-
('public', models.BooleanField(db_index=True, default=True)),
121-
('deleted', models.BooleanField(db_index=True, default=False)),
122-
('emailed', models.BooleanField(db_index=True, default=False)),
123-
('data', jsonfield.fields.JSONField(blank=True, null=True)),
124168
(
125169
'id',
126170
models.UUIDField(
@@ -138,6 +182,7 @@ class Migration(migrations.Migration):
138182
on_delete=django.db.models.deletion.CASCADE,
139183
related_name='notify_action_object',
140184
to='contenttypes.ContentType',
185+
verbose_name='action object content type',
141186
),
142187
),
143188
(
@@ -146,6 +191,7 @@ class Migration(migrations.Migration):
146191
on_delete=django.db.models.deletion.CASCADE,
147192
related_name='notify_actor',
148193
to='contenttypes.ContentType',
194+
verbose_name='actor content type',
149195
),
150196
),
151197
(
@@ -154,6 +200,7 @@ class Migration(migrations.Migration):
154200
on_delete=django.db.models.deletion.CASCADE,
155201
related_name='notifications',
156202
to=settings.AUTH_USER_MODEL,
203+
verbose_name='recipient',
157204
),
158205
),
159206
(
@@ -164,6 +211,7 @@ class Migration(migrations.Migration):
164211
on_delete=django.db.models.deletion.CASCADE,
165212
related_name='notify_target',
166213
to='contenttypes.ContentType',
214+
verbose_name='target content type',
167215
),
168216
),
169217
],
@@ -172,6 +220,8 @@ class Migration(migrations.Migration):
172220
'abstract': False,
173221
'swappable': 'OPENWISP_NOTIFICATIONS_NOTIFICATION_MODEL',
174222
'index_together': {('recipient', 'unread')},
223+
'verbose_name': 'Notification',
224+
'verbose_name_plural': 'Notifications',
175225
},
176226
),
177227
]

openwisp_notifications/templatetags/notification_tags.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
from django.core.cache import cache
33
from django.template import Library
44
from django.utils.html import format_html
5-
from notifications.templatetags.notifications_tags import (
6-
notifications_unread as base_notification_unread,
7-
)
85

96
from openwisp_notifications.swapper import load_model
107
from openwisp_notifications.utils import normalize_unread_count
@@ -14,12 +11,16 @@
1411
register = Library()
1512

1613

14+
def _get_user_unread_count(user):
15+
return user.notifications.unread().count()
16+
17+
1718
def get_notifications_count(context):
1819
user_pk = context['user'].is_authenticated and context['user'].pk
1920
cache_key = Notification.count_cache_key(user_pk)
2021
count = cache.get(cache_key)
2122
if count is None:
22-
count = base_notification_unread(context)
23+
count = _get_user_unread_count(context['user'])
2324
count = normalize_unread_count(count)
2425
cache.set(cache_key, count)
2526
return count

openwisp_notifications/tests/test_admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_zero_notifications(self):
8787
self.assertContains(r, self._expected_output())
8888

8989
def test_non_zero_notifications(self):
90-
patched_function = 'openwisp_notifications.templatetags.notification_tags.base_notification_unread'
90+
patched_function = 'openwisp_notifications.templatetags.notification_tags._get_user_unread_count'
9191
with self.subTest("Test UI for less than 100 notifications"):
9292
with patch(patched_function, return_value=10):
9393
r = self.client.get(self._url)

requirements-test.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
openwisp-utils[qa] @ https://github.com/openwisp/openwisp-utils/tarball/master
2-
django-redis~=4.12.1
3-
django-cors-headers~=3.5.0
4-
redis~=3.5.3
5-
channels_redis~=3.4.0
6-
pytest-asyncio~=0.14.0
7-
pytest-django~=4.1.0
8-
freezegun~=1.1.0
2+
django-cors-headers~=4.0.0
3+
django-redis~=5.2.0
4+
channels_redis~=4.1.0
5+
pytest-asyncio~=0.21.0
6+
pytest-django~=4.5.0
7+
freezegun~=1.2.2

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
django-notifications-hq~=1.7.0
1+
django-notifications-hq~=1.8.2
22
channels~=3.0.2
33
openwisp-users @ https://github.com/openwisp/openwisp-users/tarball/master
44
openwisp-utils[rest,celery] @ https://github.com/openwisp/openwisp-utils/tarball/master
5-
markdown~=3.2.0
5+
markdown~=3.4.3

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ def get_install_requires():
6464
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
6565
'Operating System :: OS Independent',
6666
'Framework :: Django',
67-
'Programming Language :: Python :: 3.7',
67+
'Programming Language :: Python :: 3.8',
6868
],
6969
)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
default_app_config = 'openwisp2.sample_notifications.apps.SampleNotificationsConfig'

tests/openwisp2/sample_notifications/apps.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ def connect_recievers(self):
4343
test_app_name_changed,
4444
dispatch_uid='test_app_name_changed_invalidation',
4545
)
46+
47+
48+
del OpenwispNotificationsConfig

0 commit comments

Comments
 (0)