Skip to content

Commit 4659769

Browse files
authored
Merge pull request #32 from caravancoop/feature/fix-deps
Ensure Django 2 compatibility.
2 parents 640b481 + 41e19b8 commit 4659769

File tree

9 files changed

+108
-28
lines changed

9 files changed

+108
-28
lines changed

.circleci/config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,35 @@ workflows:
44
version: 2
55
rest-auth-toolkit:
66
jobs:
7+
- test-py37
78
- test-py36
89
- test-py27
910
- check
1011

1112
jobs:
1213

14+
test-py37:
15+
docker:
16+
- image: circleci/python:3.7
17+
working_directory: ~/rest-auth-toolkit
18+
steps:
19+
- checkout
20+
- restore_cache:
21+
key: rest-auth-toolkit-py37-v1
22+
- run:
23+
name: Install CI tools
24+
command: |
25+
python3.7 -m venv venv
26+
venv/bin/pip install tox
27+
- run:
28+
name: Test with Python 3.7
29+
command: venv/bin/tox -e py37
30+
- save_cache:
31+
key: rest-auth-toolkit-py37-v1
32+
paths:
33+
- venv
34+
- .tox
35+
1336
test-py36:
1437
docker:
1538
- image: circleci/python:3.6
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.0.8 on 2018-09-21 23:51
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('accounts', '0002_auto_20180222_0012'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='user',
15+
name='last_name',
16+
field=models.CharField(blank=True, max_length=150, verbose_name='last name'),
17+
),
18+
]

demo/demo/urls.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
"""demo URL Configuration."""
22

3-
from django.conf.urls import url, include
3+
from django.urls import include, path
44
from django.contrib import admin
55

66
from rest_auth_toolkit.views import FacebookLoginView, LoginView, LogoutView, SignupView
77

88

99
auth_urlpatterns = [
10-
url(r'^signup/', SignupView.as_view(), name='signup'),
11-
url(r'^login/', LoginView.as_view(), name='login'),
12-
url(r'^logout/', LogoutView.as_view(), name='logout'),
13-
url(r'^fb-login/', FacebookLoginView.as_view(), name='fb-login'),
10+
path('signup/', SignupView.as_view(), name='signup'),
11+
path('login/', LoginView.as_view(), name='login'),
12+
path('logout/', LogoutView.as_view(), name='logout'),
13+
path('fb-login/', FacebookLoginView.as_view(), name='fb-login'),
1414
]
1515

1616
api_urlpatterns = [
17-
url(r'^account/', include('demo.accounts.urls')),
18-
url(r'', include((auth_urlpatterns, 'auth'))),
17+
path('account/', include('demo.accounts.urls')),
18+
path('', include((auth_urlpatterns, 'auth'))),
1919
]
2020

2121
urlpatterns = [
22-
url(r'^admin/', admin.site.urls),
23-
url(r'^api/', include(api_urlpatterns)),
24-
url(r'', include('demo.pages.urls')),
25-
url(r'', include('demo.pages.auth_urls')),
22+
path('admin/', admin.site.urls),
23+
path('api/', include(api_urlpatterns)),
24+
path('', include('demo.pages.urls')),
25+
path('', include('demo.pages.auth_urls')),
2626
]

demo/requirements.in

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
pip-tools
22

3-
django ~= 1.11
3+
django == 2.0.*
44
djangorestframework
55
django-debug-toolbar
66

7-
# Note: rest-framework-auth-toolkit is not here, it should already
8-
# be importable if you do pip install -e from your dev virtualenv.
9-
107
django-model-utils
118
django-shortuuidfield
129

10+
# Note: rest-framework-auth-toolkit is not here, it should already
11+
# be importable if you do "pip install -e ." from your dev virtualenv.
12+
# We do include facepy here to make sure requirements.txt
13+
# contains all transitive dependencies.
14+
facepy
15+
1316
# for the browsable API
1417
markdown
1518
pygments

demo/requirements.txt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@
44
#
55
# pip-compile --output-file requirements.txt requirements.in
66
#
7+
certifi==2018.8.24 # via requests
8+
chardet==3.0.4 # via requests
79
click==6.7 # via pip-tools
8-
django-debug-toolbar==1.9.1
9-
django-model-utils==3.1.1
10+
django-debug-toolbar==1.10.1
11+
django-model-utils==3.1.2
1012
django-shortuuidfield==0.1.3
11-
django==1.11.10
12-
djangorestframework==3.7.7
13+
django==2.0.8
14+
djangorestframework==3.8.2
15+
facepy==1.0.9
1316
first==2.0.1 # via pip-tools
17+
idna==2.7 # via requests
1418
markdown==2.6.11
15-
pip-tools==1.11.0
19+
pip-tools==2.0.2
1620
pygments==2.2.0
17-
pytz==2018.3 # via django
21+
pytz==2018.5 # via django
22+
requests==2.19.1 # via facepy
1823
shortuuid==0.5.0 # via django-shortuuidfield
19-
six==1.11.0 # via django-shortuuidfield, pip-tools
24+
six==1.11.0 # via django-shortuuidfield, facepy, pip-tools
2025
sqlparse==0.2.4 # via django-debug-toolbar
26+
urllib3==1.23 # via requests

rest_auth_toolkit/serializers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
from rest_framework import serializers
66
from rest_framework.exceptions import ValidationError
77

8-
import facepy
8+
try:
9+
import facepy
10+
except ImportError:
11+
facepy = None
912

1013

1114
User = get_user_model()

rest_auth_toolkit/views.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
from .serializers import FacebookLoginDeserializer, LoginDeserializer, SignupDeserializer
1212
from .utils import get_object_from_setting, get_setting, MissingSetting
1313

14+
try:
15+
import facepy
16+
except ImportError:
17+
facepy = None
18+
1419

1520
User = get_user_model()
1621
Token = get_object_from_setting('api_token_class')
@@ -93,6 +98,16 @@ class FacebookLoginView(generics.GenericAPIView):
9398
serializer_class = get_object_from_setting('facebook_login_serializer_class',
9499
FacebookLoginDeserializer)
95100

101+
@classmethod
102+
def as_view(cls, *args, **kwargs):
103+
if facepy is None:
104+
raise TypeError('install rest-framework-auth-toolkit[facebook] '
105+
'to enable Facebook logins')
106+
107+
# TODO error if settings are missing
108+
109+
return super(FacebookLoginView, cls).as_view(*args, **kwargs)
110+
96111
def post(self, request):
97112
deserializer = self.get_serializer(data=request.data)
98113
deserializer.is_valid(raise_exception=True)

setup.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1+
# encoding: utf-8
12
from setuptools import setup
23

34
long_description = '''
45
This libary provides mixins and views to handle signup, login and logout
56
in an API built with django-rest-framework. After login, client
67
applications get a token for the API requests.
78
8-
Email-based signups and Facebook login are supported.
9+
Email-based signups are supported out of the box.
10+
Other methods require you to specify an extra in your requirements;
11+
for example, to use Facebook login you need to depend on
12+
`rest-framework-auth-toolkit[facebook]`.
913
1014
Contrary to other similar modules, rest-auth-toolkit doess not provide
1115
a set of Django apps to include and configure in your settings, but a
1216
collection of mixins, base classes, base views and simple templates
1317
that you can integrate and customize in your own apps.
18+
19+
⚠️ This library is not stable yet, make sure to pin your dependencies.
20+
Recommended form: rest-framework-auth-toolkit == 0.9.*
1421
'''
1522

1623
setup(
@@ -28,14 +35,19 @@
2835
'Programming Language :: Python :: 2.7',
2936
'Programming Language :: Python :: 3.5',
3037
'Programming Language :: Python :: 3.6',
38+
'Programming Language :: Python :: 3.7',
39+
'Framework :: Django :: 1.11',
40+
'Framework :: Django :: 2.0',
41+
'Framework :: Django :: 2.1',
3142
],
3243
packages=[
3344
'rest_auth_toolkit',
3445
],
3546
include_package_data=True,
3647
install_requires=[
37-
'django ~= 1.11',
38-
'djangorestframework',
39-
'facepy',
48+
'django >= 1.11',
4049
],
50+
extras_require={
51+
'facebook': ['facepy'],
52+
},
4153
)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ deps =
2222
check-manifest
2323
docutils
2424
readme_renderer
25-
safety
25+
safety >= 1.8.4
2626
commands =
2727
python setup.py check -r -s -m
2828
check-manifest -v --ignore .circleci,.circleci/* --ignore-bad-ideas '*.mo'

0 commit comments

Comments
 (0)