Skip to content

Commit

Permalink
Merge pull request #11 from uppsaladatavetare/django-1.11
Browse files Browse the repository at this point in the history
Django 1.9-1.11a compatibility
  • Loading branch information
kjagiello authored Feb 8, 2017
2 parents afef4e5 + 3ed99c8 commit deb2018
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 65 deletions.
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python:

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

env:
matrix:
Expand All @@ -13,12 +14,5 @@ env:

script: make $TARGET

notifications:
slack:
on_success: change
on_failure: always
rooms:
secure: "r6d9WIlSOs+1ouByQKWvH/xVc19xhui3wqD5ghYs4ksMJX2kiN4t+n1Tan9wHjRmkLjvAszOZV0q/mVYdrgdZZkAPQCnye39WsSZyt8EDMKkmib9jBvT8S1Y3n9RaeJ+WQaT0k5kR9IpsjaWTdqH4esX3EJR5MUvrbzt5eKB7o+/mg1AH4RCsl9x+UhSaThtwqjGQd0mD0gP2bZJv2Vsgg4458DPhdGUJrgYjycetG+jACmgzIJT+Gk3RgiilrgltNnJsyMtxq6Y0P90oYlefcA6Os5EWvxrQ24RV6C+YI991JUELsREWCQMy5K9Jm+3C7l72T/ONrz2zXVzhkyvwvMBOje1wwBOlZN8juOhU9TvPh5vv4JWSYsWlyBH+rsXlePDNZs8+pnPb5XOS0PAth+WjSYt6i4xpNp0GYTy0ZM0JokGbS701scov0zCaRoQsfzQlGCZtoKzhuPfNgRE1kz16fEbBeaHjlWCUia/lVDnqdEvpjDXolqhYyt3eapWOuTfK9aIvvkBn8azU4t6o2lF1WIJACbVik8at8GJQ9ZrfiP+clHWCwG4ny4NlMgUKX3FB523mhL/aOU0ea4SuI2cVfIHBss1+hw25vBYwgy7po2u8Yr6cuxaqHqKbyfDBAf/pbf2AGUNC6za4iSzQTtQqPz6wneWLAo1bnHmO+Q="

after_success:
- bash <(curl -s https://codecov.io/bash)
28 changes: 2 additions & 26 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@
Django==1.9.0
django-bananas==1.0.8
django-enumfields==0.7.3
django-factory-boy==0.1.6
django-model-utils==2.2
django-money==0.7.4
djangorestframework==3.2.0
django-rest-swagger==0.3.4
django-bitfield==1.8.0
factory-boy==2.5.2
Pillow==2.9.0
pluggy==0.3.0
py==1.4.30
py-moneyed==0.5.0
pyflakes==0.8.1
six==1.9.0
tox==2.1.1
requests==2.8.1
pytz==2015.7

# production & dev
psycopg2==2.6.1
raven==5.8.1

# lint
flake8==2.5.4
Django==1.10.5
-r requirements/common.txt
20 changes: 20 additions & 0 deletions requirements/common.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
django-bananas==1.0.8
django-enumfields==0.8.2
django-factory-boy==0.1.6
django-model-utils==2.2
git+https://github.com/disqus/django-bitfield.git@306ba5#egg=django-bitfield
git+https://github.com/kjagiello/django-money.git@45ea5e#egg=django-money
djangorestframework==3.5.3
django-rest-swagger==2.1.1
factory-boy==2.5.2
Pillow==2.9.0
pluggy==0.3.0
py==1.4.30
py-moneyed==0.5.0
pyflakes==0.8.1
six==1.9.0
tox==2.1.1
requests==2.8.1
pytz==2015.7
psycopg2==2.6.1
raven==5.8.1
1 change: 1 addition & 0 deletions src/foobar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,6 @@ def each_context(request):
})
return ctx


_each_context = admin.site.each_context
admin.site.each_context = each_context
2 changes: 1 addition & 1 deletion src/foobar/rest/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .views.account import AccountAPI
from .views.purchase import PurchaseAPI

router = routers.SimpleRouter()
router = routers.DefaultRouter()
router.register(r'wallets', WalletAPI, 'wallets')
router.register(r'wallet_trxs', WalletTrxAPI, 'wallet_trxs')
router.register(r'products', ProductAPI, 'products')
Expand Down
57 changes: 43 additions & 14 deletions src/foobar/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv('DEBUG', True)
TEMPLATE_DEBUG = os.getenv('TEMPLATE_DEBUG', True)

ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '').split(',')
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost').split(',')


# Application definition
INSTALLED_APPS = (
'rest_framework',
'rest_framework_swagger',

'shop',
'wallet',
'foobar',
'authtoken',

'rest_framework',
'rest_framework_swagger',

'raven.contrib.django.raven_compat',

'django.contrib.auth',
Expand Down Expand Up @@ -184,13 +183,43 @@
THUNDERPUSH_APIKEY = os.getenv('THUNDERPUSH_APIKEY', 'foobar')
THUNDERPUSH_PROTO = os.getenv('THUNDERPUSH_PROTO', 'http')

TEMPLATE_CONTEXT_PROCESSORS = [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'foobar.context_processors.thunderpush_settings',
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
# insert your TEMPLATE_DIRS here
],
'APP_DIRS': True,
'OPTIONS': {
'debug': os.getenv('TEMPLATE_DEBUG', True),
'context_processors': [
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
# list if you haven't customized them:
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'foobar.context_processors.thunderpush_settings',
],
},
},
]

SWAGGER_SETTINGS = {
'USE_SESSION_AUTH': False,
'LOGIN_URL': '/',
'LOGOUT_URL': '/',
'SUPPORTED_SUBMIT_METHOD': ['get', 'post', 'put', 'delete', 'patch'],
'APIS_SORTER': 'alpha',
'VALIDATOR_URL': None,
'SECURITY_DEFINITIONS': {
'api_key': {
'type': 'apiKey',
'name': 'Authorization',
'in': 'header'
}
}
}
2 changes: 1 addition & 1 deletion src/foobar/tests/rest/test_account.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy as reverse
from rest_framework import status
from .base import AuthenticatedAPITestCase
from ..factories import CardFactory
Expand Down
2 changes: 1 addition & 1 deletion src/foobar/tests/rest/test_product.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uuid
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy as reverse
from rest_framework import status
from shop.tests.factories import (
ProductFactory,
Expand Down
2 changes: 1 addition & 1 deletion src/foobar/tests/rest/test_purchase.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy as reverse
from django.conf import settings
from rest_framework import status
from shop.tests.factories import ProductFactory
Expand Down
2 changes: 1 addition & 1 deletion src/foobar/tests/rest/test_wallet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import uuid
from decimal import Decimal
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy as reverse
from rest_framework import status
from wallet.tests.factories import WalletFactory, WalletTrxFactory
from wallet.enums import TrxType, TrxStatus
Expand Down
19 changes: 12 additions & 7 deletions src/foobar/urls.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from django.contrib import admin

from rest_framework_swagger.views import get_swagger_view
import foobar.views
import rest_framework.urls

from .rest.urls import router

urlpatterns = patterns(
'',
schema_view = get_swagger_view(title='FooBar API')

urlpatterns = [
url(r'^api/', include(router.urls, namespace='api')),
url(r'^docs/', include('rest_framework_swagger.urls')),
url(r'^api-auth/', include('rest_framework.urls',
url(r'^docs/', schema_view),
url(r'^api-auth/', include(rest_framework.urls,
namespace='rest_framework')),

url(r'^admin/foobar/account/card/(?P<card_id>\d+)',
'foobar.views.account_for_card', name='account_for_card'),
foobar.views.account_for_card, name='account_for_card'),
url(r'^admin/', include(admin.site.urls)),
)
]
2 changes: 1 addition & 1 deletion src/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class ScannerField(models.CharField):
def __init__(self, *args, **kwargs):
self.scanner = kwargs.pop('scanner')
self.scanner = kwargs.pop('scanner', None)
super().__init__(*args, **kwargs)

def formfield(self, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def test_deposit(self):
self.assertEqual(balance, Money(100, wallet_obj.currency))

def test_transfer(self):
wallet_obj1 = factories.WalletFactory.create(currency='SEK')
wallet_obj2 = factories.WalletFactory.create(currency='SEK')
wallet_obj1 = factories.WalletFactory.create(balance_currency='SEK')
wallet_obj2 = factories.WalletFactory.create(balance_currency='SEK')
factories.WalletTrxFactory.create(
wallet=wallet_obj1,
trx_status=enums.TrxStatus.FINALIZED,
Expand Down
19 changes: 16 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
[tox]
skipsdist = True
envlist = py34
envlist =
py34-{1.9,1.10,1.11},
py35-{1.9,1.10,1.11},
py36-{1.9,1.10,1.11}

[testenv]
commands=make test
deps = -r{toxinidir}/requirements.txt
deps =
-r{toxinidir}/requirements/common.txt
flake8==3.2.1
1.9: Django<1.10
1.10: Django<1.11
1.11: Django<1.12
setenv =
DJANGO_SETTINGS_MODULE=foobar.settings.test
changedir = src/
commands =
python manage.py test

0 comments on commit deb2018

Please sign in to comment.