Skip to content

Commit

Permalink
Merge pull request #28 from anx-ckreuzberger/django22_support
Browse files Browse the repository at this point in the history
Django 2.2 test support, code style, __all__ for proper imports
  • Loading branch information
anx-ckreuzberger authored Mar 25, 2019
2 parents abde4b0 + d3aa64f commit ed50088
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
- DJANGO=1.11
- DJANGO=2.0
- DJANGO=2.1
- DJANGO=2.2
- DJANGO=master
matrix:
exclude:
Expand All @@ -19,13 +20,14 @@ matrix:
- { python: "pypy", env: DJANGO=2.0 }
- { python: "2.7", env: DJANGO=2.1 }
- { python: "pypy", env: DJANGO=2.1 }
- { python: "2.7", env: DJANGO=2.2 }
- { python: "pypy", env: DJANGO=2.2 }
- { python: "2.7", env: DJANGO=master }
- { python: "pypy", env: DJANGO=master }
# Django >= 2.1 does not support Python3.4 anymore
- { python: "3.4", env: DJANGO=2.1 }
- { python: "3.4", env: DJANGO=2.2 }
- { python: "3.4", env: DJANGO=master }
# Django >= 2.2 does not support Python 3.5 anymore
- { python: "3.5", env: DJANGO=master }
allow_failures:
# newer python versions aswell as pypy may also always break our build
- python: "pypy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ class Command(BaseCommand):
def handle(self, *args, **options):
# datetime.now minus expiry hours
now_minus_expiry_time = timezone.now() - timedelta(hours=get_password_reset_token_expiry_time())
clear_expired(now_minus_expiry_time)
clear_expired(now_minus_expiry_time)
6 changes: 6 additions & 0 deletions django_rest_passwordreset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
# get the token generator class
TOKEN_GENERATOR_CLASS = get_token_generator()

__all__ = [
'ResetPasswordToken',
'get_password_reset_token_expiry_time',
'clear_expired',
]


@python_2_unicode_compatible
class ResetPasswordToken(models.Model):
Expand Down
7 changes: 6 additions & 1 deletion django_rest_passwordreset/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

from rest_framework import serializers

__all__ = [
'EmailSerializer',
'PasswordTokenSerializer',
]


class EmailSerializer(serializers.Serializer):
email = serializers.EmailField()


class PasswordTokenSerializer(serializers.Serializer):
password = serializers.CharField(label=_("Password"), style={'input_type': 'password'})
token = serializers.CharField()
token = serializers.CharField()
6 changes: 6 additions & 0 deletions django_rest_passwordreset/signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import django.dispatch

__all__ = [
'reset_password_token_created',
'pre_password_reset',
'post_password_reset',
]

reset_password_token_created = django.dispatch.Signal(
providing_args=["reset_password_token"],
)
Expand Down
13 changes: 12 additions & 1 deletion django_rest_passwordreset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

User = get_user_model()

__all__ = [
'ResetPasswordConfirm',
'ResetPasswordRequestToken',
'reset_password_confirm',
'reset_password_request_token'
]


class ResetPasswordConfirm(GenericAPIView):
"""
Expand Down Expand Up @@ -52,7 +59,11 @@ def post(self, request, *args, **kwargs):
if reset_password_token.user.has_usable_password():
pre_password_reset.send(sender=self.__class__, user=reset_password_token.user)
try:
validate_password(password, user=reset_password_token.user, password_validators=get_password_validators(settings.AUTH_PASSWORD_VALIDATORS))
validate_password(
password,
user=reset_password_token.user,
password_validators=get_password_validators(settings.AUTH_PASSWORD_VALIDATORS)
)
except ValidationError as e:
raise serializers.ValidationError(e.messages)

Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[metadata]
description-file = README.md
license_file = LICENSE


[pycodestyle]
ignore = E402,E722
max-line-length = 120
exclude = *migrations*, *tests*, *settings*
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

setup(
name='django-rest-passwordreset',
version='1.0.0alpha1',
version='1.0.0alpha2',
packages=find_packages(),
include_package_data=True,
license='BSD License',
description='An extension of django rest framework, providing a password reset strategy',
description='An extension of django rest framework, providing a configurable password reset strategy',
long_description=README,
long_description_content_type='text/markdown', # This is important for README.md in markdown format
url='https://github.com/anx-ckreuzberger/django-rest-passwordreset',
Expand All @@ -27,6 +27,7 @@
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ envlist =
{py27,py34,py35,py36,pypy,pypy3}-django111-{drf35,drf36,drf37,drf38,drf39},
{py34,py35,py36,pypy3}-django20-{drf37,drf38,drf39},
{py35,py36,pypy3}-django21-{drf37,drf38,drf39},
{py35,py36,pypy3}-django22-{drf38,drf39},
{py35,py36,pypy3}-djangomaster-{drf38,drf39}

[travis:env]
DJANGO =
1.11: django111
2.0: django20
2.1: django21
2.2: django22
master: djangomaster

[testenv]
Expand All @@ -30,5 +32,5 @@ deps =
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
django22: Django>=2.2,<3
django22: Django>=2.2rc1,<3
djangomaster: https://github.com/django/django/archive/master.tar.gz

0 comments on commit ed50088

Please sign in to comment.