From f5b9687a94f51fad63484ae1e3d0f32e2f60f360 Mon Sep 17 00:00:00 2001 From: Abdullah Esmail Date: Wed, 16 Nov 2016 12:04:55 +0300 Subject: [PATCH 1/3] replace old option_list with parser.add_argument --- .../commands/push_ios_notification.py | 68 +++++++++++-------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/ios_notifications/management/commands/push_ios_notification.py b/ios_notifications/management/commands/push_ios_notification.py index c1f60a5..9fa222a 100644 --- a/ios_notifications/management/commands/push_ios_notification.py +++ b/ios_notifications/management/commands/push_ios_notification.py @@ -11,41 +11,53 @@ class Command(BaseCommand): help = 'Create and immediately send a push notification to iOS devices' - option_list = BaseCommand.option_list + ( - make_option('--message', - help='The main message to be sent in the notification', - dest='message', - default=''), - make_option('--badge', - help='The badge number of the notification', - dest='badge', - default=None), - make_option('--sound', - help='The sound for the notification', - dest='sound', - default=''), - make_option('--service', - help='The id of the APN Service to send this notification through', - dest='service', - default=None), - make_option('--extra', - help='Custom notification payload values as a JSON dictionary', - dest='extra', - default=None), - make_option('--persist', + def add_arguments(self, parser): + parser.add_argument('--message', + help='The main message to be sent in the notification', + action='store', + dest='message', + default='') + + parser.add_argument('--badge', + help='The badge number of the notification', + action='store', + dest='badge', + default=None) + + parser.add_argument('--sound', + help='The sound for the notification', + action='store', + dest='sound', + default='') + + parser.add_argument('--service', + help='The id of the APN Service to send this notification through', + action='store', + dest='service', + default=None) + + parser.add_argument('--extra', + help='Custom notification payload values as a JSON dictionary', + action='store', + dest='extra', + default=None) + + parser.add_argument('--persist', help='Save the notification in the database after pushing it.', action='store_true', dest='persist', - default=None), - make_option('--no-persist', + default=None) + + parser.add_argument('--no-persist', help='Prevent saving the notification in the database after pushing it.', action='store_false', - dest='persist'), # Note: same dest as --persist; they are mutually exclusive - make_option('--batch-size', + dest='persist') # Note: same dest as --persist; they are mutually exclusive + + parser.add_argument('--batch-size', help='Notifications are sent to devices in batches via the APN Service. This controls the batch size. Default is 100.', + action='store', dest='chunk_size', - default=100), - ) + default=100) def handle(self, *args, **options): if options['service'] is None: From 26909daf7704f416866c2b410a010b5aea9a9d1b Mon Sep 17 00:00:00 2001 From: Abdullah Esmail Date: Wed, 16 Nov 2016 15:32:04 +0300 Subject: [PATCH 2/3] use get_user_model() for compatibility with custom user models --- ios_notifications/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios_notifications/api.py b/ios_notifications/api.py index 3e7b851..4fb0c08 100644 --- a/ios_notifications/api.py +++ b/ios_notifications/api.py @@ -6,7 +6,7 @@ from django.views.decorators.csrf import csrf_exempt from django.shortcuts import get_object_or_404 from django.db import IntegrityError -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.utils.decorators import method_decorator from .models import Device @@ -101,7 +101,7 @@ def put(self, request, **kwargs): try: user_ids = request.PUT.getlist('users') device.users.remove(*[u.id for u in device.users.all()]) - device.users.add(*User.objects.filter(id__in=user_ids)) + device.users.add(*get_user_model().objects.filter(id__in=user_ids)) except (ValueError, IntegrityError) as e: return JSONResponse({'error': e.message}, status=400) del request.PUT['users'] From 660eec467f521a071b41186c5422d8aca194325c Mon Sep 17 00:00:00 2001 From: Abdullah Esmail Date: Thu, 24 Nov 2016 13:02:53 +0300 Subject: [PATCH 3/3] add travis tests for django 1.10, remove django 1.6 and 1.7 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 60c08f5..35948dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,9 @@ python: - "2.7" script: ./runtests.sh env: - - DJANGO_VERSION=1.6.8 - - DJANGO_VERSION=1.7.8 - DJANGO_VERSION=1.8.2 - DJANGO_VERSION=1.9.4 + - DJANGO_VERSION=1.10.3 install: - pip install -q Django==$DJANGO_VERSION