Commit b01445af authored by Tim Graham's avatar Tim Graham
Browse files

Drop support for Django < 1.8

parent 61d782b0
......@@ -3,20 +3,9 @@ python: "3.5"
sudo: false
cache: pip
env:
- TOXENV=py26-django15
- TOXENV=py26-django16
- TOXENV=py27-django15
- TOXENV=py27-django16
- TOXENV=py27-django17
- TOXENV=py27-django18
- TOXENV=py27-django19
- TOXENV=py33-django15
- TOXENV=py33-django16
- TOXENV=py33-django17
- TOXENV=py33-django18
- TOXENV=py34-django15
- TOXENV=py34-django16
- TOXENV=py34-django17
- TOXENV=py34-django18
- TOXENV=py34-django19
- TOXENV=py35-django18
......
......@@ -16,7 +16,7 @@ functionality.
* Author: Bruno Renié and `contributors`_
* Licence: BSD
* Compatibility: Django 1.4+ (cryptographic signing needed)
* Compatibility: Django 1.8+
.. _contributors: https://github.com/brutasse/django-password-reset/contributors
......
......@@ -28,6 +28,10 @@ Contents:
Changelog
---------
* 1.0 (TBA):
* Drop support for Django < 1.8.
* 0.9 (2016-06-01):
* Allow token expiration time to be customized with a setting.
......
from django import forms
from django.contrib.auth import get_user_model
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.CharField()
......
import django
from unittest import SkipTest
from django.contrib.auth import get_user_model
from django.contrib.auth.tests.custom_user import CustomUser, ExtensionUser
from django.core import mail
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.utils import override_settings
from django.utils import timezone
from django.utils.six import with_metaclass
try:
from django.utils.unittest import SkipTest
except ImportError:
from unittest import SkipTest
from ..forms import PasswordRecoveryForm, PasswordResetForm
from ..utils import get_user_model
if django.VERSION >= (1, 5):
from django.contrib.auth.tests.custom_user import ( # noqa
CustomUser, ExtensionUser)
else:
CustomUser = None # noqa
ExtensionUser = None # noqa
class CustomUserVariants(type):
def __new__(cls, name, bases, dct):
if django.VERSION >= (1, 5):
for custom_user in ['auth.CustomUser', 'auth.ExtensionUser']:
suffix = custom_user.lower().replace('.', '_')
for key, fn in list(dct.items()):
if key.startswith('test') and '_CUSTOM_' not in key:
name = '{0}_CUSTOM_{1}'.format(key, suffix)
dct[name] = override_settings(
AUTH_USER_MODEL=custom_user)(fn)
for custom_user in ['auth.CustomUser', 'auth.ExtensionUser']:
suffix = custom_user.lower().replace('.', '_')
for key, fn in list(dct.items()):
if key.startswith('test') and '_CUSTOM_' not in key:
name = '{0}_CUSTOM_{1}'.format(key, suffix)
dct[name] = override_settings(
AUTH_USER_MODEL=custom_user)(fn)
return super(CustomUserVariants, cls).__new__(cls, name, bases, dct)
......
try:
from django.contrib.auth import get_user_model
except ImportError:
from django.contrib.auth.models import User
def get_user_model():
return User
def get_username(user):
username_field = getattr(user, 'USERNAME_FIELD', 'username')
return getattr(user, username_field)
import datetime
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.sites.shortcuts import get_current_site
from django.core import signing
from django.core.mail import send_mail
from django.core.urlresolvers import reverse, reverse_lazy
......@@ -12,14 +14,9 @@ from django.utils.decorators import method_decorator
from django.views import generic
from django.views.decorators.debug import sensitive_post_parameters
try:
from django.contrib.sites.shortcuts import get_current_site
except ImportError:
from django.contrib.sites.models import get_current_site
from .forms import PasswordRecoveryForm, PasswordResetForm
from .signals import user_recovers_password
from .utils import get_user_model, get_username
class SaltMixin(object):
......@@ -84,7 +81,7 @@ class Recover(SaltMixin, generic.FormView):
context = {
'site': self.get_site(),
'user': self.user,
'username': get_username(self.user),
'username': self.user.get_username(),
'token': signing.dumps(self.user.pk, salt=self.salt),
'secure': self.request.is_secure(),
}
......@@ -154,7 +151,7 @@ class Reset(SaltMixin, generic.FormView):
ctx = super(Reset, self).get_context_data(**kwargs)
if 'invalid' not in ctx:
ctx.update({
'username': get_username(self.user),
'username': self.user.get_username(),
'token': self.kwargs['token'],
})
return ctx
......
......@@ -4,23 +4,18 @@ import sys
import warnings
import django
from django.test.runner import DiscoverRunner
warnings.simplefilter('always')
os.environ['DJANGO_SETTINGS_MODULE'] = 'password_reset.tests.settings'
try:
from django.test.runner import DiscoverRunner
except ImportError:
from discover_runner import DiscoverRunner
def runtests():
parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)
if django.VERSION >= (1, 7):
django.setup()
django.setup()
runner = DiscoverRunner(verbosity=1, interactive=True,
failfast=bool(os.environ.get('FAILFAST')))
......
......@@ -19,7 +19,7 @@ setup(
description='Class-based views for password reset.',
long_description=open('README.rst').read(),
install_requires=[
'Django>=1.4',
'Django>=1.8',
],
classifiers=[
'Development Status :: 4 - Beta',
......
[tox]
envlist =
py26-django1{5,6},
py27-django1{5,6,7,8,9},
py33-django1{5,6,7,8},
py34-django1{5,6,7,8,9},
py27-django1{8,9},
py33-django18,
py34-django1{8,9},
py35-django1{8,9},
docs, lint
[testenv]
commands = python -Wall setup.py test
basepython =
py26: python2.6
py27: python2.7
py33: python3.3
py34: python3.4
py35: python3.5
deps =
django-discover-runner
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment