Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Django 3.0 #80

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ sudo: false
language: python

python:
- "3.5"
- "3.7"

env:
- TOXENV=py27-django18-normal,py33-django18-normal
- TOXENV=py27-django18-custom,py33-django18-custom
- TOXENV=py27-django19-normal,py34-django19-normal
- TOXENV=py27-django19-custom,py34-django19-custom
- TOXENV=py27-django110-normal,py34-django110-normal,py35-django110-normal
- TOXENV=py27-django110-custom,py34-django110-custom,py35-django110-custom
- TOXENV=py37-django30-normal
- TOXENV=py37-django30-custom

cache:
directories:
Expand Down
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.PHONY: help setup clean pep8 tests run

# Version package
VERSION=$(shell python -c 'import allaccess; print(allaccess.__version__)')

PROJECT_HOME = "`pwd`"

help:
@echo
@echo "Please use 'make <target>' where <target> is one of"
@echo

@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

setup: ## Install project dependencies
@pip install -r $(PROJECT_HOME)/requirements.txt

clean: ## Clear *.pyc files, etc
@rm -rf build dist *.egg-info
@find . \( -name '*.pyc' -o -name '__pycache__' -o -name '**/*.pyc' -o -name '*~' \) -delete

tests: clean ## Make tests
@python runtests.py

dist: clean ## Make dist
@python setup.py sdist

publish: clean dist ## Make publish
@echo 'Ready to release version ${VERSION}? (ctrl+c to abort)' && read
twine upload dist/*
@git tag ${VERSION}
@git push --tags
2 changes: 1 addition & 1 deletion allaccess/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""


__version__ = '0.10.0.dev.0'
__version__ = '0.10.0'


default_app_config = 'allaccess.apps.AllAccessConfig'
Expand Down
2 changes: 1 addition & 1 deletion allaccess/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class AuthorizedServiceBackend(ModelBackend):
"Authentication backend for users registered with remote OAuth provider."

def authenticate(self, provider=None, identifier=None):
def authenticate(self, request, provider=None, identifier=None):
"Fetch user for a given provider by id."
provider_q = Q(provider__name=provider)
if isinstance(provider, Provider):
Expand Down
2 changes: 1 addition & 1 deletion allaccess/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, *args, **kwargs):
self.cipher = self.encryption_class()
super(EncryptedField, self).__init__(*args, **kwargs)

def from_db_value(self, value, expression, connection, context):
def from_db_value(self, value, expression, connection):
if value is None:
return value
value = force_bytes(value)
Expand Down
3 changes: 0 additions & 3 deletions allaccess/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.conf import settings
from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from .clients import get_client
from .fields import EncryptedField
Expand All @@ -15,7 +14,6 @@ def get_by_natural_key(self, name):
return self.get(name=name)


@python_2_unicode_compatible
class Provider(models.Model):
"Configuration for OAuth provider."

Expand Down Expand Up @@ -53,7 +51,6 @@ def get_by_natural_key(self, identifier, provider):
return self.get(identifier=identifier, provider=provider)


@python_2_unicode_compatible
class AccountAccess(models.Model):
"Authorized remote OAuth provider."

Expand Down
2 changes: 1 addition & 1 deletion allaccess/tests/custom/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import hashlib

from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.encoding import smart_bytes, force_text

from allaccess.views import OAuthRedirect, OAuthCallback
Expand Down
2 changes: 1 addition & 1 deletion allaccess/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals

from django.conf import settings
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.test import override_settings, RequestFactory

from .base import AllAccessTestCase, AccountAccess, get_user_model, skipIfCustomUser
Expand Down
6 changes: 3 additions & 3 deletions allaccess/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.auth import authenticate, login, get_user_model
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http import Http404
from django.shortcuts import redirect
from django.utils.encoding import smart_bytes, force_text
Expand Down Expand Up @@ -151,7 +151,7 @@ def get_user_id(self, provider, info):

def handle_existing_user(self, provider, user, access, info):
"Login user and redirect."
login(self.request, user)
login(self.request, user, backend='allaccess.backends.AuthorizedServiceBackend')
return redirect(self.get_login_redirect(provider, user, access))

def handle_login_failure(self, provider, reason):
Expand All @@ -166,5 +166,5 @@ def handle_new_user(self, provider, access, info):
access.user = user
AccountAccess.objects.filter(pk=access.pk).update(user=user)
user = authenticate(provider=access.provider, identifier=access.identifier)
login(self.request, user)
login(self.request, user, backend='allaccess.backends.AuthorizedServiceBackend')
return redirect(self.get_login_redirect(provider, user, access, True))
2 changes: 1 addition & 1 deletion docs/customize-views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ the URL pattern.

.. code-block:: python

from django.core.urlresolvers import reverse
from django.urls import reverse
from allaccess.views import OAuthRedirect

class AssociateRedirect(OAuthRedirect):
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ requests-oauthlib==0.7.0
requests==2.11.1
oauthlib==2.0.0
pycrypto==2.6.1
Django==1.10.3
Django==3.0.3
gunicorn>=19.6,<19.7
dj-database-url==0.3.0
dj-static==0.0.6
static3==0.7.0
psycopg2==2.6.2
17 changes: 16 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,28 @@
}
},
INSTALLED_APPS=INSTALLED_APPS,
MIDDLEWARE_CLASSES=(
MIDDLEWARE=(
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
),
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
],
AUTHENTICATION_BACKENDS=(
'allaccess.backends.AuthorizedServiceBackend',
),
Expand Down
16 changes: 7 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,29 @@ def read_file(filename):


setup(
name='django-all-access',
name='django3-all-access',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are obviously welcome to publish your own version of this package under the terms of the BSD license but that shouldn't be part of this PR.

version=__import__('allaccess').__version__,
author='Mark Lavin',
author_email='[email protected]',
author='Storm',
author_email='[email protected]',
packages=find_packages(),
include_package_data=True,
url='https://github.com/mlavin/django-all-access',
url='https://github.com/stormers/django-all-access',
license='BSD',
description=' '.join(__import__('allaccess').__doc__.splitlines()).strip(),
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Framework :: Django',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 3.0',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'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',
'Programming Language :: Python :: 3.7',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules',
],
Expand Down
14 changes: 5 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
[tox]
envlist = py{27,33}-django{18}-{normal,custom},py{27,34,35}-django{19,110}-{normal,custom},docs
envlist = py{34,35, 36, 37}-django{30}-{normal,custom},docs

[testenv]
commands = coverage run runtests.py
basepython =
py27: python2.7
py33: python3.3
py34: python3.4
py35: python3.5
py36: python3.6
py37: python3.7
deps =
coverage>=4.2,<4.3
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
py27: mock>=1.0,<2.0
django30: Django>=3.0,<3.1
setenv =
custom: SWAPPED=1

[testenv:docs]
basepython = python2.7
basepython = python3.4
deps = Sphinx==1.1.3
commands =
{envbindir}/sphinx-build -a -n -b html -d docs/_build/doctrees docs docs/_build/html