Skip to content

Commit

Permalink
Merge pull request jpadilla#224 from mblayman/version-docs
Browse files Browse the repository at this point in the history
Update supported versions in README and index.
  • Loading branch information
Carlton Gibson committed Apr 3, 2016
2 parents 118fb88 + 9b206d3 commit 00f76e4
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 116 deletions.
20 changes: 1 addition & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ env:
- TOX_ENV=py27-flake8
- TOX_ENV=py27-docs

- TOX_ENV=py27-django1.7-drf2.4
- TOX_ENV=py27-django1.7-drf3.0
- TOX_ENV=py27-django1.7-drf3.1
- TOX_ENV=py27-django1.7-drf3.2
- TOX_ENV=py27-django1.7-drf3.3

- TOX_ENV=py27-django1.8-drf3.0
- TOX_ENV=py27-django1.8-drf3.1
- TOX_ENV=py27-django1.8-drf3.2
Expand All @@ -21,23 +15,11 @@ env:
- TOX_ENV=py27-django1.9-drf3.2
- TOX_ENV=py27-django1.9-drf3.3

- TOX_ENV=py33-django1.7-drf2.4
- TOX_ENV=py33-django1.7-drf3.0
- TOX_ENV=py33-django1.7-drf3.1
- TOX_ENV=py33-django1.7-drf3.2
- TOX_ENV=py33-django1.7-drf3.3

- TOX_ENV=py33-django1.8-drf3.0
- TOX_ENV=py33-django1.8-drf3.1
- TOX_ENV=py33-django1.8-drf3.2
- TOX_ENV=py33-django1.8-drf3.3

- TOX_ENV=py34-django1.7-drf2.4
- TOX_ENV=py34-django1.7-drf3.0
- TOX_ENV=py34-django1.7-drf3.1
- TOX_ENV=py34-django1.7-drf3.2
- TOX_ENV=py34-django1.7-drf3.3

- TOX_ENV=py34-django1.8-drf3.0
- TOX_ENV=py34-django1.8-drf3.1
- TOX_ENV=py34-django1.8-drf3.2
Expand All @@ -51,7 +33,7 @@ matrix:
fast_finish: true

install:
- pip install tox
- pip install tox

script:
- tox -e $TOX_ENV
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Requirements
------------

- Python (2.7, 3.3, 3.4)
- Django (1.6, 1.7, 1.8)
- Django REST Framework (2.4, 3.0, 3.1, 3.2)
- Django (1.8, 1.9)
- Django REST Framework (3.0, 3.1, 3.2, 3.3)

Installation
------------
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ If you want to know more about JWT, check out the following resources:
## Requirements

- Python (2.7, 3.3, 3.4)
- Django (1.6, 1.7)
- Django REST Framework (2.4, 3.0, 3.1, 3.2)
- Django (1.8, 1.9)
- Django REST Framework (3.0, 3.1, 3.2, 3.3)

## Security

Expand Down
2 changes: 1 addition & 1 deletion rest_framework_jwt/authentication.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import jwt

from django.contrib.auth import get_user_model
from django.utils.encoding import smart_text
from django.utils.translation import ugettext as _
from rest_framework import exceptions
from rest_framework.authentication import (
BaseAuthentication, get_authorization_header
)

from rest_framework_jwt.compat import get_user_model
from rest_framework_jwt.settings import api_settings


Expand Down
56 changes: 12 additions & 44 deletions rest_framework_jwt/compat.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,22 @@
from distutils.version import StrictVersion
from django.contrib.auth import get_user_model

import rest_framework
from rest_framework import serializers
from django.forms import widgets


DRF_VERSION_INFO = StrictVersion(rest_framework.VERSION).version
DRF2 = DRF_VERSION_INFO[0] == 2
DRF3 = DRF_VERSION_INFO[0] == 3
class Serializer(serializers.Serializer):
@property
def object(self):
return self.validated_data


if DRF2:
class Serializer(serializers.Serializer):
pass
class PasswordField(serializers.CharField):

class PasswordField(serializers.CharField):
widget = widgets.PasswordInput
else:
class Serializer(serializers.Serializer):
@property
def object(self):
return self.validated_data

class PasswordField(serializers.CharField):

def __init__(self, *args, **kwargs):
if 'style' not in kwargs:
kwargs['style'] = {'input_type': 'password'}
else:
kwargs['style']['input_type'] = 'password'
super(PasswordField, self).__init__(*args, **kwargs)


def get_user_model():
try:
from django.contrib.auth import get_user_model
except ImportError: # Django < 1.5
from django.contrib.auth.models import User
else:
User = get_user_model()

return User
def __init__(self, *args, **kwargs):
if 'style' not in kwargs:
kwargs['style'] = {'input_type': 'password'}
else:
kwargs['style']['input_type'] = 'password'
super(PasswordField, self).__init__(*args, **kwargs)


def get_username_field():
Expand All @@ -59,11 +35,3 @@ def get_username(user):
username = user.username

return username


def get_request_data(request):
if DRF2:
data = request.DATA
else:
data = request.data
return data
6 changes: 2 additions & 4 deletions rest_framework_jwt/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
from calendar import timegm
from datetime import datetime, timedelta

from django.contrib.auth import authenticate
from django.contrib.auth import authenticate, get_user_model
from django.utils.translation import ugettext as _
from rest_framework import serializers
from .compat import Serializer

from rest_framework_jwt.settings import api_settings
from rest_framework_jwt.compat import (
get_user_model, get_username_field, PasswordField
)
from rest_framework_jwt.compat import get_username_field, PasswordField


User = get_user_model()
Expand Down
5 changes: 1 addition & 4 deletions rest_framework_jwt/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from rest_framework.response import Response

from .settings import api_settings
from .compat import get_request_data
from .serializers import (
JSONWebTokenSerializer, RefreshJSONWebTokenSerializer,
VerifyJSONWebTokenSerializer
Expand Down Expand Up @@ -52,9 +51,7 @@ def get_serializer(self, *args, **kwargs):
return serializer_class(*args, **kwargs)

def post(self, request, *args, **kwargs):
serializer = self.get_serializer(
data=get_request_data(request)
)
serializer = self.get_serializer(data=request.data)

if serializer.is_valid():
user = serializer.object.get('user') or request.user
Expand Down
35 changes: 0 additions & 35 deletions tests/test_compat.py

This file was deleted.

6 changes: 1 addition & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
[tox]
envlist =
py27-{flake8,docs},
{py27,py33,py34}-django{1.6,1.7}-drf{2.4,3.0,3.1,3.2,3.3},
{py27,py33,py34}-django{1.8,1.9}-drf{3.0,3.1,3.2,3.3}

[testenv]
commands = ./runtests.py --fast {posargs}
setenv =
PYTHONDONTWRITEBYTECODE=1
deps =
django1.6: Django==1.6.11 # Should track minimum supported
django1.7: Django==1.7.11 # Should track maximum supported
django1.8: Django==1.8.7 # Should track maximum supported
django1.9: Django==1.9.0 # Should track maximum supported
drf2.4: djangorestframework==2.4.5 # Should track minimum supported
drf3.0: djangorestframework==3.0.5 # Should track maximum supported
drf3.1: djangorestframework==3.1.3 # Should track maximum supported
drf3.2: djangorestframework==3.2.2 # Should track maximum supported
drf3.3: djangorestframework==3.3.2 # Should track maximum supported
py27-django1.6-drf{2.4,3.0,3.1,3.2,3.3}: -rrequirements/optionals.txt
py27-django{1.6,1.7,1.8,1.9}-drf{3.1,3.2,3.3}: djangorestframework-oauth==1.0.1
py27-django{1.8,1.9}-drf{3.1,3.2,3.3}: djangorestframework-oauth==1.0.1
-rrequirements/testing.txt

[testenv:py27-flake8]
Expand Down

0 comments on commit 00f76e4

Please sign in to comment.