Skip to content

Commit f21a4d4

Browse files
committed
Drop support for Python<2.7 and Django<1.8
1 parent d7ce842 commit f21a4d4

File tree

11 files changed

+15
-286
lines changed

11 files changed

+15
-286
lines changed

.travis.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
language: python
22
python:
3-
- "2.6"
43
- "2.7"
54
- "3.2"
65
- "3.3"
76
- "3.4"
87
env:
9-
- DJANGO=1.5
10-
- DJANGO=1.6
11-
- DJANGO=1.7
12-
matrix:
13-
exclude:
14-
- python: "2.6"
15-
env: DJANGO=1.7
16-
allow_failures:
17-
python:
18-
- "3.2"
19-
- "3.3"
20-
- "3.4"
8+
- DJANGO=1.8
219
install:
2210
- pip install -q Django==$DJANGO --use-mirrors
2311
- pip install -r requirements.txt --use-mirrors

README.rst

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ single messages.
2222

2323
Dependencies
2424
------------
25-
All versions of Django 1.0 and newer should be supported, however no guarantees are made for versions older than 1.4.
25+
Django 1.8 is required. Support for older versions is available in the release 1.2.1.
2626

27-
Tastypie support should work on Tastypie 0.9.11 and newer.
28-
29-
Django versions older than 1.5 require 'six' to be installed.
30-
Django versions older than 1.7 require 'south' to be installed.
31-
Django versions older than 1.8 require 'django-uuidfield' to be installed.
27+
Tastypie support should work on Tastypie 0.11.0 and newer.
3228

3329

3430
Setup
@@ -55,10 +51,7 @@ Note: If you are planning on running your project with `DEBUG=True`, then make s
5551

5652
You can learn more about APNS certificates here: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ProvisioningDevelopment.html
5753

58-
Native Django migrations are supported on Django 1.7 and beyond. The app will automatically
59-
fall back to South on older versions, however you will also need the following setting::
60-
61-
SOUTH_MIGRATION_MODULES = {"push_notifications": "push_notifications.south_migrations"}
54+
Native Django migrations are in use. `manage.py migrate` will install and migrate all models.
6255

6356

6457
Settings list
@@ -164,4 +157,4 @@ When registered, the APIs will show up at <api_root>/device/apns and <api_root>/
164157
Python 3 support
165158
----------------
166159

167-
django-push-notifications is compatible with Python 3. Django 1.8 or higher is recommended.
160+
django-push-notifications is fully compatible with Python 3.

push_notifications/admin.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
from django.contrib import admin
2+
from django.contrib.auth import get_user_model
23
from django.utils.translation import ugettext_lazy as _
34
from .models import APNSDevice, GCMDevice, get_expired_tokens
45

56

6-
def _user__username():
7-
try:
8-
from django.contrib.auth import get_user_model
9-
except ImportError:
10-
# Django <1.5
11-
return "user__username"
12-
return "user__%s" % (get_user_model().USERNAME_FIELD)
7+
User = get_user_model()
138

149

1510
class DeviceAdmin(admin.ModelAdmin):
1611
list_display = ("__unicode__", "device_id", "user", "active", "date_created")
17-
search_fields = ("name", "device_id", _user__username())
12+
search_fields = ("name", "device_id", "user__%s" % (User.USERNAME_FIELD))
1813
list_filter = ("active", )
1914
actions = ("send_message", "send_bulk_message", "prune_devices", "enable", "disable")
2015

push_notifications/fields.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,12 @@
33
from django import forms
44
from django.core.validators import RegexValidator
55
from django.db import models, connection
6+
from django.utils import six
67
from django.utils.translation import ugettext_lazy as _
78

8-
try:
9-
from django.utils import six
10-
except ImportError:
11-
import six
129

10+
__all__ = ["HexadecimalField", "HexIntegerField"]
1311

14-
__all__ = ["HexadecimalField", "HexIntegerField", "UUIDField"]
15-
16-
# Django <1.8 compatibility: UUIDField
17-
if hasattr(models, "UUIDField"):
18-
UUIDField = models.UUIDField
19-
else:
20-
from uuidfield import UUIDField
2112

2213
hex_re = re.compile(r"^0x[0-9a-fA-F]+$")
2314
postgres_engines = [
@@ -81,9 +72,3 @@ def formfield(self, **kwargs):
8172
defaults.update(kwargs)
8273
# yes, that super call is right
8374
return super(models.IntegerField, self).formfield(**defaults)
84-
85-
try:
86-
from south.modelsinspector import add_introspection_rules
87-
add_introspection_rules([], ["^push_notifications\.fields\.HexIntegerField"])
88-
except ImportError:
89-
pass

push_notifications/migrations/0001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Migration(migrations.Migration):
2020
('name', models.CharField(max_length=255, null=True, verbose_name='Name', blank=True)),
2121
('active', models.BooleanField(default=True, help_text='Inactive devices will not be sent notifications', verbose_name='Is active')),
2222
('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Creation date', null=True)),
23-
('device_id', push_notifications.fields.UUIDField(help_text=b'UDID / UIDevice.identifierForVendor()', max_length=32, null=True, verbose_name='Device ID', blank=True)),
23+
('device_id', models.UUIDField(help_text=b'UDID / UIDevice.identifierForVendor()', max_length=32, null=True, verbose_name='Device ID', blank=True)),
2424
('registration_id', models.CharField(unique=True, max_length=64, verbose_name='Registration ID')),
2525
('user', models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True)),
2626
],

push_notifications/models.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
from django.conf import settings
22
from django.db import models
33
from django.utils.translation import ugettext_lazy as _
4-
from .fields import HexIntegerField, UUIDField
5-
6-
7-
# Compatibility with custom user models, while keeping backwards-compatibility with <1.5
8-
AUTH_USER_MODEL = getattr(settings, "AUTH_USER_MODEL", "auth.User")
4+
from .fields import HexIntegerField
95

106

117
class Device(models.Model):
128
name = models.CharField(max_length=255, verbose_name=_("Name"), blank=True, null=True)
139
active = models.BooleanField(verbose_name=_("Is active"), default=True,
1410
help_text=_("Inactive devices will not be sent notifications"))
15-
user = models.ForeignKey(AUTH_USER_MODEL, blank=True, null=True)
11+
user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True)
1612
date_created = models.DateTimeField(verbose_name=_("Creation date"), auto_now_add=True, null=True)
1713

1814
class Meta:
@@ -27,7 +23,6 @@ def __unicode__(self):
2723
class GCMDeviceManager(models.Manager):
2824
def get_queryset(self):
2925
return GCMDeviceQuerySet(self.model)
30-
get_query_set = get_queryset # Django < 1.6 compatiblity
3126

3227

3328
class GCMDeviceQuerySet(models.query.QuerySet):
@@ -67,7 +62,6 @@ def send_message(self, message, **kwargs):
6762
class APNSDeviceManager(models.Manager):
6863
def get_queryset(self):
6964
return APNSDeviceQuerySet(self.model)
70-
get_query_set = get_queryset # Django < 1.6 compatiblity
7165

7266

7367
class APNSDeviceQuerySet(models.query.QuerySet):
@@ -79,7 +73,7 @@ def send_message(self, message, **kwargs):
7973

8074

8175
class APNSDevice(Device):
82-
device_id = UUIDField(verbose_name=_("Device ID"), blank=True, null=True, db_index=True,
76+
device_id = models.UUIDField(verbose_name=_("Device ID"), blank=True, null=True, db_index=True,
8377
help_text="UDID / UIDevice.identifierForVendor()")
8478
registration_id = models.CharField(verbose_name=_("Registration ID"), max_length=64, unique=True)
8579

push_notifications/south_migrations/0001_initial.py

Lines changed: 0 additions & 116 deletions
This file was deleted.

push_notifications/south_migrations/0002_auto__add_field_apnsdevice_date_created__add_field_gcmdevice_date_created.py

Lines changed: 0 additions & 108 deletions
This file was deleted.

push_notifications/south_migrations/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)