Skip to content

Commit 7f43ae8

Browse files
committed
[TASK] Upgrade django to 1.11, upgrade social auth library, upgrade other libraries.
1 parent 42bbf70 commit 7f43ae8

File tree

11 files changed

+111
-106
lines changed

11 files changed

+111
-106
lines changed

requirements.txt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
# Django & Core
2-
Django==1.8.18
3-
pymysql==0.7.11
4-
django-material==0.13.1
5-
urllib3==1.20
6-
django-crispy-forms==1.6.1
7-
django-watson==1.3.1
8-
django_compressor==2.1.1
9-
django-cors-headers==2.0.2
10-
python-social-auth==0.2.21
11-
django-stronghold==0.2.8
2+
Django==1.11.9
3+
pymysql==0.8.0
4+
django-material==1.2.2
5+
urllib3==1.22
6+
django-crispy-forms==1.7.0
7+
django-watson==1.5.0
8+
django_compressor==2.2
9+
django-cors-headers==2.1.0
10+
django-stronghold==0.3.0
1211

13-
jsonfield==2.0.1
12+
social-auth-app-django==2.1.0
13+
# OLD: python-social-auth==0.2.21
14+
15+
jsonfield==2.0.2
1416

1517
# Debuging & Logging
16-
colorlog==2.10.0
17-
django-debug-toolbar==1.7
18-
django-extensions==1.7.8
19-
Werkzeug==0.12.1
18+
colorlog==3.1.0
19+
django-debug-toolbar==1.9.1
20+
django-extensions==1.9.9
21+
Werkzeug==0.14.1
2022

2123
# Documentation
2224
sphinx
2325
sphinx_rtd_theme
2426
django-docs==0.2.1
2527

2628
# API
27-
djangorestframework==3.6.2
29+
djangorestframework==3.7.7
2830
pygments==2.2.0
2931

3032
# Testing and tools
31-
fake-factory
33+
Faker
3234

3335
# Server
3436
gunicorn

src/apps/accounts/middleware.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
from django.contrib import messages
22
from django.shortcuts import render
3-
from social.exceptions import AuthCanceled, AuthForbidden
3+
from social_core.exceptions import AuthCanceled, AuthForbidden
44

55

66
class SocialAuthExceptionMiddleware:
7+
8+
def __init__(self, get_response):
9+
self.get_response = get_response
10+
11+
def __call__(self, request):
12+
response = self.get_response(request)
13+
return response
14+
715
def process_exception(self, request, exception):
816
if type(exception) == AuthCanceled:
917
messages.warning(request, 'Login session is canceled!')

src/apps/accounts/views.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from django.conf import settings
22
from django.contrib.auth import authenticate, login as django_login, logout as django_logout
3-
from django.shortcuts import redirect, render_to_response
4-
from django.template import RequestContext
3+
from django.shortcuts import redirect, render
54
from django.views.generic import TemplateView, View
65
from rest_framework.authtoken.models import Token
7-
from social.apps.django_app.utils import get_backend, BACKENDS
6+
from social_django.utils import get_backend, BACKENDS
87
from stronghold.views import StrongholdPublicMixin
98

109
from apps.accounts.utils import get_social_button
@@ -38,11 +37,11 @@ def get(self, request, *args, **kwargs):
3837

3938
form = forms.LoginForm()
4039

41-
return render_to_response(self.template_name, {
40+
return render(request, self.template_name, {
4241
'form': form,
4342
'next': redirect_url,
4443
'social': self.social_config
45-
}, context_instance=RequestContext(request))
44+
})
4645

4746
def post(self, request, *args, **kwargs):
4847
form = forms.LoginForm(data=request.POST)
@@ -59,11 +58,11 @@ def post(self, request, *args, **kwargs):
5958
return redirect(redirect_url)
6059
form.errors['__all__'] = form.error_class(["Email and password combination is wrong"])
6160

62-
return render_to_response(self.template_name, {
61+
return render(request, self.template_name, {
6362
'form': form,
6463
'next': redirect_url,
6564
'social': self.social_config
66-
}, context_instance=RequestContext(request))
65+
})
6766

6867

6968
class Logout(View):

src/apps/mails/apps.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from django.apps import AppConfig
22

33
from apps.core.menu import Menu, Item
4-
from apps.mails import models
54

65

76
class MailsConfig(AppConfig):

src/config/settings/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@
1515

1616
# Debug override
1717
DEBUG = bool(int(os.getenv('DJANGO_IS_DEBUG', True)))
18-
TEMPLATE_DEBUG = DEBUG

src/config/settings/base.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@
9090
'django.contrib.messages',
9191
'django.contrib.staticfiles',
9292
'django.contrib.humanize',
93+
'django_extensions',
9394
'stronghold',
9495
'crispy_forms',
9596
'material',
96-
'material.admin',
97+
'material.frontend',
9798
'rest_framework',
9899
'rest_framework.authtoken',
99100
'compressor',
@@ -103,7 +104,7 @@
103104

104105
# Add app for social login.
105106
if 'social' in local.AUTHENTICATION and type(local.AUTHENTICATION['social']) is dict:
106-
INSTALLED_APPS.append('social.apps.django_app.default')
107+
INSTALLED_APPS.append('social_django')
107108

108109
# Add source apps
109110
INSTALLED_APPS += [
@@ -137,48 +138,30 @@
137138
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
138139

139140
####
140-
# Templates & Middleware
141+
# Middleware
141142
####
142-
if 'TEMPLATE_CONTEXT_PROCESSORS' not in globals():
143-
TEMPLATE_CONTEXT_PROCESSORS = []
144-
145-
TEMPLATE_CONTEXT_PROCESSORS += (
146-
'django.core.context_processors.request',
147-
'django.contrib.messages.context_processors.messages',
148-
'apps.core.context.add_global_context',
149-
'apps.filters.context.add_global_context',
150-
'apps.mails.context.add_global_context',
151-
)
152-
153143
# Add social processors
154144
SOCIAL_ENABLED = False
155145
if 'social' in local.AUTHENTICATION and 'enabled' in local.AUTHENTICATION['social'] and local.AUTHENTICATION['social'][
156146
'enabled']:
157147
SOCIAL_ENABLED = True
158148

159-
TEMPLATE_CONTEXT_PROCESSORS += (
160-
'social.apps.django_app.context_processors.login_redirect',
161-
'social.apps.django_app.context_processors.backends',
162-
)
163-
164149
CRISPY_TEMPLATE_PACK = 'bootstrap3'
165150

166-
MIDDLEWARE_CLASSES = (
151+
MIDDLEWARE = [
152+
'django.middleware.security.SecurityMiddleware',
167153
'django.contrib.sessions.middleware.SessionMiddleware',
168-
169-
'corsheaders.middleware.CorsMiddleware',
154+
'django.middleware.locale.LocaleMiddleware',
170155
'django.middleware.common.CommonMiddleware',
171156
'django.middleware.csrf.CsrfViewMiddleware',
172-
173157
'django.contrib.auth.middleware.AuthenticationMiddleware',
174-
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
175-
176158
'django.contrib.messages.middleware.MessageMiddleware',
177159
'django.middleware.clickjacking.XFrameOptionsMiddleware',
178160

161+
'corsheaders.middleware.CorsMiddleware',
179162
'stronghold.middleware.LoginRequiredMiddleware',
180163
'apps.accounts.middleware.SocialAuthExceptionMiddleware',
181-
)
164+
]
182165

183166
####
184167
# Authentication and security
@@ -216,26 +199,26 @@
216199

217200
# Add default social options
218201
if SOCIAL_ENABLED:
219-
SOCIAL_AUTH_STRATEGY = 'social.strategies.django_strategy.DjangoStrategy'
220-
SOCIAL_AUTH_STORAGE = 'social.apps.django_app.default.models.DjangoStorage'
202+
SOCIAL_AUTH_STRATEGY = 'social_django.strategy.DjangoStrategy'
203+
SOCIAL_AUTH_STORAGE = 'social_django.models.DjangoStorage'
221204

222205
SOCIAL_AUTH_PIPELINE = (
223-
'social.pipeline.social_auth.social_details',
224-
'social.pipeline.social_auth.social_uid',
225-
'social.pipeline.social_auth.auth_allowed',
226-
'social.pipeline.social_auth.social_user',
227-
'social.pipeline.social_auth.associate_by_email',
228-
'social.pipeline.user.get_username',
229-
'social.pipeline.user.create_user',
230-
'social.pipeline.social_auth.associate_user',
231-
'social.pipeline.social_auth.load_extra_data',
232-
'social.pipeline.user.user_details',
206+
'social_core.pipeline.social_auth.social_details',
207+
'social_core.pipeline.social_auth.social_uid',
208+
'social_core.pipeline.social_auth.auth_allowed',
209+
'social_core.pipeline.social_auth.social_user',
210+
'social_core.pipeline.social_auth.associate_by_email',
211+
'social_core.pipeline.user.get_username',
212+
'social_core.pipeline.user.create_user',
213+
'social_core.pipeline.social_auth.associate_user',
214+
'social_core.pipeline.social_auth.load_extra_data',
215+
'social_core.pipeline.user.user_details',
233216
)
234217

235218
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
236-
'social.pipeline.disconnect.get_entries',
237-
'social.pipeline.disconnect.revoke_tokens',
238-
'social.pipeline.disconnect.disconnect'
219+
'social_core.pipeline.disconnect.get_entries',
220+
'social_core.pipeline.disconnect.revoke_tokens',
221+
'social_core.pipeline.disconnect.disconnect'
239222
)
240223

241224
# Add social pipelines
@@ -250,10 +233,27 @@
250233
####
251234
# Template and cache
252235
####
253-
TEMPLATE_LOADERS = (
254-
'django.template.loaders.filesystem.Loader',
255-
'django.template.loaders.app_directories.Loader',
256-
)
236+
TEMPLATES = [
237+
{
238+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
239+
'DIRS': [],
240+
'APP_DIRS': True,
241+
'OPTIONS': {
242+
'context_processors': [
243+
'django.template.context_processors.debug',
244+
'django.template.context_processors.request',
245+
'django.contrib.auth.context_processors.auth',
246+
'django.contrib.messages.context_processors.messages',
247+
248+
'apps.core.context.add_global_context',
249+
'apps.filters.context.add_global_context',
250+
'apps.mails.context.add_global_context',
251+
'social_django.context_processors.login_redirect',
252+
'social_django.context_processors.backends',
253+
],
254+
},
255+
},
256+
]
257257

258258
STATICFILES_FINDERS = (
259259
'django.contrib.staticfiles.finders.FileSystemFinder',

src/config/settings/dev.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
# Add debug apps.
66
####
77

8-
INSTALLED_APPS += (
8+
INSTALLED_APPS += [
99
'debug_toolbar',
10-
'django_extensions',
11-
)
10+
]
1211

13-
STRONGHOLD_PUBLIC_URLS += (
12+
STRONGHOLD_PUBLIC_URLS += [
1413
'__debug__',
15-
)
14+
]
1615

17-
MIDDLEWARE_CLASSES += (
16+
MIDDLEWARE += [
1817
'debug_toolbar.middleware.DebugToolbarMiddleware',
19-
)
18+
]
2019

2120
####
2221
# Broker

src/config/settings/live.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
####
44
# Cache & Templates
55
####
6-
TEMPLATE_LOADERS = (
7-
('django.template.loaders.cached.Loader', (
8-
'django.template.loaders.filesystem.Loader',
9-
'django.template.loaders.app_directories.Loader',
10-
)),
11-
)
6+
# TEMPLATE_LOADERS = (
7+
# ('django.template.loaders.cached.Loader', (
8+
# 'django.template.loaders.filesystem.Loader',
9+
# 'django.template.loaders.app_directories.Loader',
10+
# )),
11+
# )
1212

1313
####
1414
# Logging

src/config/settings/local.default.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
# Turn debug on or off
1515
DEBUG = False
16-
TEMPLATE_DEBUG = DEBUG
1716

1817
# Authentication options. See example for details
1918
# See http://psa.matiasaguirre.net/docs/index.html for details on social authentication configuration.
@@ -23,22 +22,22 @@
2322
'enabled': True,
2423
'backends': (
2524
# Enable your backends here. Note! Only GoogleOAuth2 is fully tested!
26-
'social.backends.google.GoogleOAuth2',
27-
'social.backends.github.GithubOAuth2',
28-
'social.backends.bitbucket.BitbucketOAuth2',
29-
'social.backends.facebook.FacebookOAuth2',
30-
# 'social.backends.dropbox.DropboxOAuth2',
31-
# 'social.backends.flickr.FlickrOAuth',
32-
# 'social.backends.instagram.InstagramOAuth2',
33-
# 'social.backends.live.LiveOAuth2',
34-
# 'social.backends.linkedin.LinkedinOAuth2',
35-
# 'social.backends.odnoklassniki.OdnoklassnikiOAuth2',
36-
# 'social.backends.reddit.RedditOAuth2',
37-
# 'social.backends.soundcloud.SoundcloudOAuth2',
38-
# 'social.backends.tumblr.TumblrOAuth',
39-
# 'social.backends.twitter.TwitterOAuth',
40-
# 'social.backends.vk.VKOAuth2',
41-
# 'social.backends.yahoo.YahooOAuth',
25+
'social_core.backends.google.GoogleOAuth2',
26+
'social_core.backends.github.GithubOAuth2',
27+
'social_core.backends.bitbucket.BitbucketOAuth2',
28+
'social_core.backends.facebook.FacebookOAuth2',
29+
# 'social_core.backends.dropbox.DropboxOAuth2',
30+
# 'social_core.backends.flickr.FlickrOAuth',
31+
# 'social_core.backends.instagram.InstagramOAuth2',
32+
# 'social_core.backends.live.LiveOAuth2',
33+
# 'social_core.backends.linkedin.LinkedinOAuth2',
34+
# 'social_core.backends.odnoklassniki.OdnoklassnikiOAuth2',
35+
# 'social_core.backends.reddit.RedditOAuth2',
36+
# 'social_core.backends.soundcloud.SoundcloudOAuth2',
37+
# 'social_core.backends.tumblr.TumblrOAuth',
38+
# 'social_core.backends.twitter.TwitterOAuth',
39+
# 'social_core.backends.vk.VKOAuth2',
40+
# 'social_core.backends.yahoo.YahooOAuth',
4241
),
4342
'options': {
4443
'SOCIAL_AUTH_GOOGLE_OAUTH2_KEY': 'key.apps.goog...',

src/config/settings/local.travis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
# Turn debug on or off
1818
DEBUG = True
19-
TEMPLATE_DEBUG = DEBUG
2019

2120
# Authentication options. See example for details
2221
# See http://psa.matiasaguirre.net/docs/index.html for details on social authentication configuration.

0 commit comments

Comments
 (0)