Skip to content

Commit b01445a

Browse files
committed
Drop support for Django < 1.8
1 parent 61d782b commit b01445a

File tree

10 files changed

+26
-71
lines changed

10 files changed

+26
-71
lines changed

.travis.yml

-11
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@ python: "3.5"
33
sudo: false
44
cache: pip
55
env:
6-
- TOXENV=py26-django15
7-
- TOXENV=py26-django16
8-
- TOXENV=py27-django15
9-
- TOXENV=py27-django16
10-
- TOXENV=py27-django17
116
- TOXENV=py27-django18
127
- TOXENV=py27-django19
13-
- TOXENV=py33-django15
14-
- TOXENV=py33-django16
15-
- TOXENV=py33-django17
168
- TOXENV=py33-django18
17-
- TOXENV=py34-django15
18-
- TOXENV=py34-django16
19-
- TOXENV=py34-django17
209
- TOXENV=py34-django18
2110
- TOXENV=py34-django19
2211
- TOXENV=py35-django18

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ functionality.
1616

1717
* Author: Bruno Renié and `contributors`_
1818
* Licence: BSD
19-
* Compatibility: Django 1.4+ (cryptographic signing needed)
19+
* Compatibility: Django 1.8+
2020

2121
.. _contributors: https://github.com/brutasse/django-password-reset/contributors
2222

docs/index.rst

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Contents:
2828
Changelog
2929
---------
3030

31+
* 1.0 (TBA):
32+
33+
* Drop support for Django < 1.8.
34+
3135
* 0.9 (2016-06-01):
3236

3337
* Allow token expiration time to be customized with a setting.

password_reset/forms.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from django import forms
2+
from django.contrib.auth import get_user_model
23
from django.core.validators import validate_email
34
from django.db.models import Q
45
from django.utils.translation import ugettext_lazy as _
56
from django.conf import settings
67

7-
from .utils import get_user_model
8-
98

109
class PasswordRecoveryForm(forms.Form):
1110
username_or_email = forms.CharField()

password_reset/tests/tests.py

+10-21
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
1-
import django
1+
from unittest import SkipTest
22

3+
from django.contrib.auth import get_user_model
4+
from django.contrib.auth.tests.custom_user import CustomUser, ExtensionUser
35
from django.core import mail
46
from django.core.urlresolvers import reverse
57
from django.test import TestCase
68
from django.test.utils import override_settings
79
from django.utils import timezone
810
from django.utils.six import with_metaclass
9-
try:
10-
from django.utils.unittest import SkipTest
11-
except ImportError:
12-
from unittest import SkipTest
1311

1412
from ..forms import PasswordRecoveryForm, PasswordResetForm
15-
from ..utils import get_user_model
16-
17-
if django.VERSION >= (1, 5):
18-
from django.contrib.auth.tests.custom_user import ( # noqa
19-
CustomUser, ExtensionUser)
20-
else:
21-
CustomUser = None # noqa
22-
ExtensionUser = None # noqa
2313

2414

2515
class CustomUserVariants(type):
2616
def __new__(cls, name, bases, dct):
27-
if django.VERSION >= (1, 5):
28-
for custom_user in ['auth.CustomUser', 'auth.ExtensionUser']:
29-
suffix = custom_user.lower().replace('.', '_')
30-
for key, fn in list(dct.items()):
31-
if key.startswith('test') and '_CUSTOM_' not in key:
32-
name = '{0}_CUSTOM_{1}'.format(key, suffix)
33-
dct[name] = override_settings(
34-
AUTH_USER_MODEL=custom_user)(fn)
17+
for custom_user in ['auth.CustomUser', 'auth.ExtensionUser']:
18+
suffix = custom_user.lower().replace('.', '_')
19+
for key, fn in list(dct.items()):
20+
if key.startswith('test') and '_CUSTOM_' not in key:
21+
name = '{0}_CUSTOM_{1}'.format(key, suffix)
22+
dct[name] = override_settings(
23+
AUTH_USER_MODEL=custom_user)(fn)
3524
return super(CustomUserVariants, cls).__new__(cls, name, bases, dct)
3625

3726

password_reset/utils.py

-12
This file was deleted.

password_reset/views.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import datetime
22

33
from django.conf import settings
4+
from django.contrib.auth import get_user_model
5+
from django.contrib.sites.shortcuts import get_current_site
46
from django.core import signing
57
from django.core.mail import send_mail
68
from django.core.urlresolvers import reverse, reverse_lazy
@@ -12,14 +14,9 @@
1214
from django.views import generic
1315
from django.views.decorators.debug import sensitive_post_parameters
1416

15-
try:
16-
from django.contrib.sites.shortcuts import get_current_site
17-
except ImportError:
18-
from django.contrib.sites.models import get_current_site
1917

2018
from .forms import PasswordRecoveryForm, PasswordResetForm
2119
from .signals import user_recovers_password
22-
from .utils import get_user_model, get_username
2320

2421

2522
class SaltMixin(object):
@@ -84,7 +81,7 @@ def send_notification(self):
8481
context = {
8582
'site': self.get_site(),
8683
'user': self.user,
87-
'username': get_username(self.user),
84+
'username': self.user.get_username(),
8885
'token': signing.dumps(self.user.pk, salt=self.salt),
8986
'secure': self.request.is_secure(),
9087
}
@@ -154,7 +151,7 @@ def get_context_data(self, **kwargs):
154151
ctx = super(Reset, self).get_context_data(**kwargs)
155152
if 'invalid' not in ctx:
156153
ctx.update({
157-
'username': get_username(self.user),
154+
'username': self.user.get_username(),
158155
'token': self.kwargs['token'],
159156
})
160157
return ctx

runtests.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,18 @@
44
import warnings
55

66
import django
7+
from django.test.runner import DiscoverRunner
78

89
warnings.simplefilter('always')
910

1011
os.environ['DJANGO_SETTINGS_MODULE'] = 'password_reset.tests.settings'
1112

12-
try:
13-
from django.test.runner import DiscoverRunner
14-
except ImportError:
15-
from discover_runner import DiscoverRunner
16-
1713

1814
def runtests():
1915
parent = os.path.dirname(os.path.abspath(__file__))
2016
sys.path.insert(0, parent)
2117

22-
if django.VERSION >= (1, 7):
23-
django.setup()
18+
django.setup()
2419

2520
runner = DiscoverRunner(verbosity=1, interactive=True,
2621
failfast=bool(os.environ.get('FAILFAST')))

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
description='Class-based views for password reset.',
2020
long_description=open('README.rst').read(),
2121
install_requires=[
22-
'Django>=1.4',
22+
'Django>=1.8',
2323
],
2424
classifiers=[
2525
'Development Status :: 4 - Beta',

tox.ini

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
[tox]
22
envlist =
3-
py26-django1{5,6},
4-
py27-django1{5,6,7,8,9},
5-
py33-django1{5,6,7,8},
6-
py34-django1{5,6,7,8,9},
3+
py27-django1{8,9},
4+
py33-django18,
5+
py34-django1{8,9},
76
py35-django1{8,9},
87
docs, lint
98

109
[testenv]
1110
commands = python -Wall setup.py test
1211
basepython =
13-
py26: python2.6
1412
py27: python2.7
1513
py33: python3.3
1614
py34: python3.4
1715
py35: python3.5
1816
deps =
19-
django-discover-runner
20-
django15: Django>=1.5,<1.6
21-
django16: Django>=1.6,<1.7
22-
django17: Django>=1.7,<1.8
2317
django18: Django>=1.8,<1.9
2418
django19: Django>=1.9,<1.10
2519

0 commit comments

Comments
 (0)