Skip to content

Commit

Permalink
Support Django 2.0 (#315)
Browse files Browse the repository at this point in the history
* Remove support for Django <1.11 and test agagainst Django 2.0

* Set version 2.0a1

* Bump 2.0a2

* Isort

* Travis tweaks

* Test against django 2.0 and prep release

* Update README and fix tests
  • Loading branch information
joshblum authored Dec 5, 2017
1 parent 2430cd3 commit d1f5537
Show file tree
Hide file tree
Showing 27 changed files with 98 additions and 143 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ language: python
sudo: false
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6

install:
- pip install -r requirements.txt
pip install -r test-requirements.txt

before_script:
- rm -rf build
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
django-registration-redux changelog
===================================

Version 1.10, TBD
Version 2.0, 05 December, 2017
----------------
* BACKWARDS-INCOMPATIBLE CHANGE: Remove support for Django < 1.11.
* BACKWARDS-INCOMPATIBLE CHANGE: Remove `registration/urls.py` in favor of
`registration/backends/default/urls.py`
* Feature: Add compatibility for Django 2.0.

Version 1.9, 16 November, 2017
----------------
Expand Down
30 changes: 13 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,9 @@

If you have issues with the "django-registration-redux" package then please `raise them here`_.

This is a fairly simple user-registration application for Django,
designed to make allowing user signups as painless as possible. It
requires a functional installation of Django 1.8 or newer, but has no
other dependencies.

Django 2.0 Alpha Pre-Release
----------------------------

We have a pre-release available to begin testing against Django 2.0. You can
install this version by running::

pip install django-registration-redux==2.0a3

If you find any issues with this alpha release, please submit an issue or a
pull request (compared against the `django-2.0 branch <https://github.com/macropin/django-registration/tree/django-2.0>`_). Once Django 2.0 is officially released, we will take our version out of alpha and
officially drop support for Django<1.11 on master.
This is a fairly simple user-registration application for Django, designed to
make allowing user signups as painless as possible. It requires a functional
installation of Django 1.11 or newer, but has no other dependencies.


Installation
Expand All @@ -64,7 +51,15 @@ somewhere on your Python path; this is useful if you're working from a
Git checkout.

Note that this application requires Python 2.7/3.4 or later, and a
functional installation of Django 1.8 or newer.
functional installation of Django 1.11 or newer.

If you are running on Django <=1.11, you can install a previous version of
`django-registration-redux`, which supports older versions of Django. See the
`CHANGELOG`_ for support details. Older versions will receive minor bug fixes as
needed, but are no longer actively developed::

pip install django-registration-redux==1.9


Getting started with development
--------------------------------
Expand Down Expand Up @@ -112,3 +107,4 @@ Django-registration-redux is licensed under `BSD License`.

.. _`available online`: https://django-registration-redux.readthedocs.org/
.. _`raise them here`: https://github.com/macropin/django-registration/issues
.. _`CHANGELOG`: https://github.com/macropin/django-registration/blob/master/CHANGELOG
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
# built documents.
#
# The short X.Y version.
version = '1.9'
version = '2.0'
# The full version, including alpha/beta/rc tags.
release = '1.9'
release = '2.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ Tips and tricks

from django.conf.urls import url, include
from django.contrib.auth import views as auth_views
from django.core.urlresolvers import reverse_lazy
from django.urls import reverse_lazy
url(r'^password/reset/$',
auth_views.PasswordResetView.as_view(
success_url=reverse_lazy('auth_password_reset_done'),
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Quick start guide

Before installing |project|, you'll need to have a copy of
`Django <http://www.djangoproject.com>`_ already installed. For the
|version| release, Django 1.8 or newer is required.
|version| release, Django 1.11 or newer is required.

For further information, consult the `Django download page
<http://www.djangoproject.com/download/>`_, which offers convenient
Expand Down
4 changes: 2 additions & 2 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Release notes
=============

The |version| release of |project| supports Python 2.7, 3.4, 3.5 and
Django 1.8, 1.9, and 1.10.
The |version| release of |project| supports Python 2.7, 3.4, 3.5, 3.6 and
Django 1.11 and 2.0.
11 changes: 9 additions & 2 deletions docs/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ between versions you should refer to the `CHANGELOG
Django version requirement
--------------------------

As of |version|, |project| requires Django 1.8 or newer;
As of |version|, |project| requires Django 1.11 or newer;
older Django releases may work, but are officially unsupported. Additionally,
|project| officially supports Python 2.7, 3.3, 3.4, 3.5, and 3.6.
|project| officially supports Python 2.7, 3.4, and 3.5, 3.6.


Backwards-incompatible changes
------------------------------
Version 2.0
```````````

- Removed support for Django < 1.11.
- Removed `registration/urls.py` in favor of
`registration/backends/default/urls.py`


Version 1.9
```````````
Expand Down
2 changes: 1 addition & 1 deletion registration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (1, 9, 0, 'final', 0)
VERSION = (2, 0, 0, 'final', 0)


def get_version():
Expand Down
103 changes: 33 additions & 70 deletions registration/auth_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,75 +22,38 @@
consult a specific backend's documentation for details.
"""
import django
from django.conf.urls import url
from django.contrib.auth import views as auth_views
from django.core.urlresolvers import reverse_lazy

if django.VERSION >= (1, 11):
urlpatterns = [
url(r'^login/$',
auth_views.LoginView.as_view(
template_name='registration/login.html'),
name='auth_login'),
url(r'^logout/$',
auth_views.LogoutView.as_view(
template_name='registration/logout.html'),
name='auth_logout'),
url(r'^password/change/$',
auth_views.PasswordChangeView.as_view(
success_url=reverse_lazy('auth_password_change_done')),
name='auth_password_change'),
url(r'^password/change/done/$',
auth_views.PasswordChangeDoneView.as_view(),
name='auth_password_change_done'),
url(r'^password/reset/$',
auth_views.PasswordResetView.as_view(
success_url=reverse_lazy('auth_password_reset_done')),
name='auth_password_reset'),
url(r'^password/reset/complete/$',
auth_views.PasswordResetCompleteView.as_view(),
name='auth_password_reset_complete'),
url(r'^password/reset/done/$',
auth_views.PasswordResetDoneView.as_view(),
name='auth_password_reset_done'),
url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
auth_views.PasswordResetConfirmView.as_view(
success_url=reverse_lazy('auth_password_reset_complete')),
name='auth_password_reset_confirm'),
]
else:
urlpatterns = [
url(r'^login/$',
auth_views.login,
{'template_name': 'registration/login.html'},
name='auth_login'),
url(r'^logout/$',
auth_views.logout,
{'template_name': 'registration/logout.html'},
name='auth_logout'),
url(r'^password/change/$',
auth_views.password_change,
{'post_change_redirect': reverse_lazy(
'auth_password_change_done')},
name='auth_password_change'),
url(r'^password/change/done/$',
auth_views.password_change_done,
name='auth_password_change_done'),
url(r'^password/reset/$',
auth_views.password_reset,
{'post_reset_redirect': reverse_lazy(
'auth_password_reset_done')},
name='auth_password_reset'),
url(r'^password/reset/complete/$',
auth_views.password_reset_complete,
name='auth_password_reset_complete'),
url(r'^password/reset/done/$',
auth_views.password_reset_done,
name='auth_password_reset_done'),
url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
auth_views.password_reset_confirm,
{'post_reset_redirect': reverse_lazy(
'auth_password_reset_complete')},
name='auth_password_reset_confirm'),
]
from django.urls import reverse_lazy

urlpatterns = [
url(r'^login/$',
auth_views.LoginView.as_view(
template_name='registration/login.html'),
name='auth_login'),
url(r'^logout/$',
auth_views.LogoutView.as_view(
template_name='registration/logout.html'),
name='auth_logout'),
url(r'^password/change/$',
auth_views.PasswordChangeView.as_view(
success_url=reverse_lazy('auth_password_change_done')),
name='auth_password_change'),
url(r'^password/change/done/$',
auth_views.PasswordChangeDoneView.as_view(),
name='auth_password_change_done'),
url(r'^password/reset/$',
auth_views.PasswordResetView.as_view(
success_url=reverse_lazy('auth_password_reset_done')),
name='auth_password_reset'),
url(r'^password/reset/complete/$',
auth_views.PasswordResetCompleteView.as_view(),
name='auth_password_reset_complete'),
url(r'^password/reset/done/$',
auth_views.PasswordResetDoneView.as_view(),
name='auth_password_reset_done'),
url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
auth_views.PasswordResetConfirmView.as_view(
success_url=reverse_lazy('auth_password_reset_complete')),
name='auth_password_reset_confirm'),
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='SupervisedRegistrationProfile',
fields=[
('registrationprofile_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='registration.RegistrationProfile')),
('registrationprofile_ptr', models.OneToOneField(
parent_link=True,
auto_created=True,
on_delete=models.CASCADE,
primary_key=True,
serialize=False,
to='registration.RegistrationProfile')
),
],
bases=('registration.registrationprofile',),
),
Expand Down
3 changes: 2 additions & 1 deletion registration/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from registration import admin, urls
from registration import admin
from registration.backends.default import urls


def test():
Expand Down
6 changes: 3 additions & 3 deletions registration/tests/admin_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from django.contrib.admin import helpers
from django.core import mail
from django.core import urlresolvers
from django.test import TestCase
from django.test.client import Client
from django.test.utils import override_settings
from django.urls import reverse

from registration.models import RegistrationProfile
from registration.users import UserModel
Expand Down Expand Up @@ -40,7 +40,7 @@ def test_activate_users(self):

self.assertFalse(profile.activated)

registrationprofile_list = urlresolvers.reverse(
registrationprofile_list = reverse(
'admin:registration_registrationprofile_changelist')
post_data = {
'action': 'activate_users',
Expand All @@ -58,7 +58,7 @@ def test_resend_activation_email(self):
new_user = UserModel().objects.create_user(**self.user_info)
profile = RegistrationProfile.objects.create_profile(new_user)

registrationprofile_list = urlresolvers.reverse(
registrationprofile_list = reverse(
'admin:registration_registrationprofile_changelist')
post_data = {
'action': 'resend_activation_email',
Expand Down
2 changes: 1 addition & 1 deletion registration/tests/admin_approval_backend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
from django.urls import reverse

from .default_backend import DefaultBackendViewTests

Expand Down
2 changes: 1 addition & 1 deletion registration/tests/default_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.core import mail
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse

from registration.backends.default.views import RegistrationView
from registration.forms import RegistrationForm
Expand Down
4 changes: 2 additions & 2 deletions registration/tests/simple_backend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test import override_settings
from django.urls import reverse

from registration.forms import RegistrationForm
from registration.users import UserModel
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_registration(self):

# New user must be logged in.
resp = self.client.get(reverse('registration_register'), follow=True)
self.failUnless(resp.context['user'].is_authenticated())
self.failUnless(resp.context['user'].is_authenticated)

def test_registration_failure(self):
"""
Expand Down
15 changes: 0 additions & 15 deletions registration/urls.py

This file was deleted.

2 changes: 1 addition & 1 deletion registration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def dispatch(self, request, *args, **kwargs):
"""
if ACCOUNT_AUTHENTICATED_REGISTRATION_REDIRECTS:
if self.request.user.is_authenticated():
if self.request.user.is_authenticated:
if settings.LOGIN_REDIRECT_URL is not None:
return redirect(settings.LOGIN_REDIRECT_URL)
else:
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
Sphinx
twine
pytest>3.2.1
Django>1.8
docutils==0.12
Django>1.11
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@ def run_tests(self):
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand Down
Loading

0 comments on commit d1f5537

Please sign in to comment.