Skip to content

Commit d2a7e46

Browse files
authored
Merge pull request #86 from benjaoming/django2.2
Django 2.2 support
2 parents e6dadb7 + a55f5e1 commit d2a7e46

File tree

12 files changed

+72
-39
lines changed

12 files changed

+72
-39
lines changed

.travis.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ matrix:
2626
sudo: false
2727
env: DJANGO="2.0"
2828
- python: 3.5
29-
dist: trusty
29+
dist: xenial
3030
sudo: false
3131
env: DJANGO="2.1"
32+
- python: 3.5
33+
dist: xenial
34+
sudo: false
35+
env: DJANGO="2.2"
3236

3337
- python: 3.6
3438
dist: trusty
@@ -39,9 +43,13 @@ matrix:
3943
sudo: false
4044
env: DJANGO="2.0"
4145
- python: 3.6
42-
dist: trusty
46+
dist: xenial
4347
sudo: false
4448
env: DJANGO="2.1"
49+
- python: 3.6
50+
dist: xenial
51+
sudo: false
52+
env: DJANGO="2.2"
4553

4654
- python: 3.7
4755
dist: xenial
@@ -51,11 +59,19 @@ matrix:
5159
dist: xenial
5260
sudo: true
5361
env: DJANGO="2.1"
62+
- python: 3.7
63+
dist: xenial
64+
sudo: true
65+
env: DJANGO="2.2"
5466

5567
- python: pypy
5668
dist: trusty
5769
sudo: false
5870
env: DJANGO="2.1"
71+
- python: pypy
72+
dist: trusty
73+
sudo: false
74+
env: DJANGO="2.2"
5975

6076
install:
6177
- pip install tox tox-travis coverage codecov

django_nyt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
_disable_notifications = False
22

3-
__version__ = "1.1.2"
3+
__version__ = "1.1.3"
44

55
default_app_config = "django_nyt.apps.DjangoNytConfig"

django_nyt/management/commands/notifymail.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
from django.core import mail
1111
from django.core.management.base import BaseCommand
1212
from django.template.loader import render_to_string
13-
from django.utils.translation import activate, deactivate, gettext as _
14-
from django_nyt import models, settings as nyt_settings
13+
from django.utils.translation import activate
14+
from django.utils.translation import deactivate
15+
from django.utils.translation import gettext as _
16+
17+
from django_nyt import models
18+
from django_nyt import settings as nyt_settings
1519

1620
# Daemon / mail loop sleep between each database poll (seconds)
1721
SLEEP_TIME = 120
@@ -166,10 +170,8 @@ def send_loop(self, connection, sleep_time):
166170
if last_sent:
167171
user_settings = models.Settings.objects.filter(
168172
interval__lte=(
169-
(started_sending_at -
170-
last_sent).seconds //
171-
60) //
172-
60).order_by('user')
173+
(started_sending_at - last_sent).seconds // 60) // 60
174+
).order_by('user')
173175
else:
174176
user_settings = None
175177

django_nyt/models.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
from django.core.exceptions import ValidationError
33
from django.db import models
44
from django.db.models import Q
5-
from django.db.models.signals import post_delete, post_save
5+
from django.db.models.signals import post_delete
6+
from django.db.models.signals import post_save
67
from django.dispatch import receiver
78
from django.utils.translation import gettext_lazy as _
9+
810
from django_nyt import settings
911

1012
_notification_type_cache = {}
@@ -266,8 +268,7 @@ def create_notifications(cls, key, **kwargs):
266268
)
267269
if object_id:
268270
subscriptions = subscriptions.filter(
269-
Q(object_id=object_id) |
270-
Q(object_id=None)
271+
Q(object_id=object_id) | Q(object_id=None)
271272
)
272273
if recipient_users:
273274
subscriptions = subscriptions.filter(
@@ -286,9 +287,9 @@ def create_notifications(cls, key, **kwargs):
286287

287288
# Check if it's the same as the previous message
288289
latest = subscription.latest
289-
if latest and (latest.message == kwargs.get('message', None) and
290-
latest.url == kwargs.get('url', None) and
291-
latest.is_viewed is False):
290+
if latest and (latest.message == kwargs.get('message', None)
291+
and latest.url == kwargs.get('url', None)
292+
and latest.is_viewed is False):
292293
# Both message and URL are the same, and it hasn't been viewed
293294
# so just increment occurrence count.
294295
latest.occurrences = latest.occurrences + 1

django_nyt/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
############
6060

6161
ENABLE_CHANNELS = (
62-
'channels' in django_settings.INSTALLED_APPS and
63-
not getattr(django_settings, 'NYT_CHANNELS_DISABLE', False)
62+
'channels' in django_settings.INSTALLED_APPS
63+
and not getattr(django_settings, 'NYT_CHANNELS_DISABLE', False)
6464
)
6565
"""Channels are enabled automatically when 'channels' application is installed,
6666
however you can explicitly disable it with NYT_CHANNELS_DISABLE."""

django_nyt/urls.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
app_name = 'nyt'
77

88
urlpatterns = [
9-
url('^json/get/$', views.get_notifications, name='json_get'),
10-
url('^json/get/(?P<latest_id>\d+)/$', views.get_notifications, name='json_get'),
11-
url('^json/mark-read/$', views.mark_read, name='json_mark_read_base'),
12-
url('^json/mark-read/(\d+)/$', views.mark_read, name='json_mark_read'),
13-
url('^json/mark-read/(?P<id_lte>\d+)/(?P<id_gte>\d+)/$', views.mark_read, name='json_mark_read'),
14-
url('^goto/(?P<notification_id>\d+)/$', views.goto, name='goto'),
15-
url('^goto/$', views.goto, name='goto_base'),
9+
url(r'^json/get/$', views.get_notifications, name='json_get'),
10+
url(r'^json/get/(?P<latest_id>\d+)/$', views.get_notifications, name='json_get'),
11+
url(r'^json/mark-read/$', views.mark_read, name='json_mark_read_base'),
12+
url(r'^json/mark-read/(\d+)/$', views.mark_read, name='json_mark_read'),
13+
url(r'^json/mark-read/(?P<id_lte>\d+)/(?P<id_gte>\d+)/$', views.mark_read, name='json_mark_read'),
14+
url(r'^goto/(?P<notification_id>\d+)/$', views.goto, name='goto'),
15+
url(r'^goto/$', views.goto, name='goto_base'),
1616
]
1717

1818

django_nyt/views.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from django.contrib.auth.decorators import login_required
22
from django.db.models import Q
3-
from django.shortcuts import get_object_or_404, redirect
3+
from django.shortcuts import get_object_or_404
4+
from django.shortcuts import redirect
45
from django.utils.translation import gettext as _
6+
57
from django_nyt import models
6-
from django_nyt.decorators import json_view, login_required_ajax
8+
from django_nyt.decorators import json_view
9+
from django_nyt.decorators import login_required_ajax
710

811

912
@login_required_ajax
@@ -36,8 +39,7 @@ def get_notifications(
3639
"""
3740

3841
notifications = models.Notification.objects.filter(
39-
Q(subscription__settings__user=request.user) |
40-
Q(user=request.user),
42+
Q(subscription__settings__user=request.user) | Q(user=request.user),
4143
)
4244

4345
if is_viewed is not None:
@@ -73,8 +75,7 @@ def goto(request, notification_id=None):
7375
return redirect(referer)
7476
notification = get_object_or_404(
7577
models.Notification,
76-
Q(subscription__settings__user=request.user) |
77-
Q(user=request.user),
78+
Q(subscription__settings__user=request.user) | Q(user=request.user),
7879
id=notification_id
7980
)
8081
notification.is_viewed = True
@@ -89,8 +90,7 @@ def goto(request, notification_id=None):
8990
def mark_read(request, id_lte, notification_type_id=None, id_gte=None):
9091

9192
notifications = models.Notification.objects.filter(
92-
Q(subscription__settings__user=request.user) |
93-
Q(user=request.user),
93+
Q(subscription__settings__user=request.user) | Q(user=request.user),
9494
id__lte=id_lte
9595
)
9696

docs/release_notes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Release Notes
22
=============
33

4+
1.1.3
5+
-----
6+
7+
Added
8+
^^^^^
9+
10+
* Django 2.2 support (added to test matrix)
11+
* Linting (no changes to functionality)
12+
13+
414
1.1.2
515
-----
616

runtests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
'django.contrib.contenttypes',
1111
'django.contrib.sessions',
1212
'django.contrib.admin',
13+
'django.contrib.messages',
1314
'django.contrib.humanize',
1415
'django.contrib.sites',
1516
'django_nyt',

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ universal = 0
55
description-file = README.rst
66

77
[flake8]
8-
ignore = E226,E302,E303,E41,E501
8+
ignore = E226,E302,E303,E41,E501,W503
99
max-line-length = 160
1010
max-complexity = 10
1111
exclude = */*migrations

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
keywords=["django", "notification" "alerts"],
1818
packages=find_packages(),
1919
zip_safe=False,
20-
install_requires=["django>=1.11,<2.2"],
20+
install_requires=["django>=1.11,<2.3"],
2121
classifiers=[
2222
'Development Status :: 5 - Production/Stable',
2323
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',

tox.ini

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
[tox]
22
# Ensure you add to .travis.yml if you add here
3-
envlist = {py34,py35,py36}-django{111,20,21}
3+
envlist = {py34,py35,py36,py37,pypy}-django{111,20,21,22}
44

55
[travis]
66
python =
77
3.4: py34
8-
3.5: py35,lint
9-
3.6: py36
8+
3.5: py35
9+
3.6: py36,lint
1010
3.7: py37
11+
pypy: py
1112

1213
[travis:env]
1314
DJANGO =
1415
1.11: django111
1516
2.0: django20
1617
2.1: django21
18+
2.2: django22
1719
LINT =
1820
yes: lint
1921

@@ -30,16 +32,17 @@ deps =
3032
django111: Django>=1.11,<2.0
3133
django20: Django>=2.0,<2.1
3234
django21: Django>=2.1,<2.2
35+
django22: Django>=2.2,<2.3
3336

3437
basepython =
3538
py34: python3.4
3639
py35: python3.5
3740
py36: python3.6
3841
py37: python3.7
39-
42+
pypy: python
4043

4144
[testenv:lint]
42-
basepython = python3.5
45+
basepython = python3.6
4346
deps = flake8
4447
commands =
4548
flake8 django_nyt

0 commit comments

Comments
 (0)