From 40d5ac7e3afae8c38813e91731a648d29b844ee9 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 6 Mar 2014 23:22:37 +0100 Subject: [PATCH] Upgrade django-social-auth to python-social-auth --- .pipignore | 14 +++++ fabfile.py | 2 +- requirements.pip | 7 --- requirements.txt | 15 ++++++ umap/settings/base.py | 26 ++++----- umap/settings/local.py.sample | 73 ++++++++++++++------------ umap/templates/registration/login.html | 4 +- umap/urls.py | 12 ++--- 8 files changed, 92 insertions(+), 61 deletions(-) create mode 100644 .pipignore delete mode 100644 requirements.pip create mode 100644 requirements.txt diff --git a/.pipignore b/.pipignore new file mode 100644 index 00000000..b811199c --- /dev/null +++ b/.pipignore @@ -0,0 +1,14 @@ +flake8 +pip-tools +ipdb +coverage +factory-boy +django-debug-toolbar +ipython +pep8 +mock +unittest2 +transifex-client +django-discover-runner +mccabe +pyflakes \ No newline at end of file diff --git a/fabfile.py b/fabfile.py index 49f7d13b..a7de6f91 100644 --- a/fabfile.py +++ b/fabfile.py @@ -7,7 +7,7 @@ env.project_name = 'umap' env.repository = 'https://yohanboniface@bitbucket.org/yohanboniface/umap.git' env.local_branch = 'master' env.remote_ref = 'origin/master' -env.requirements_file = 'requirements.pip' +env.requirements_file = 'requirements.txt' env.restart_sudo = False diff --git a/requirements.pip b/requirements.pip deleted file mode 100644 index 955defea..00000000 --- a/requirements.pip +++ /dev/null @@ -1,7 +0,0 @@ -Django==1.5.5 -South==0.7.6 -django-leaflet-storage==0.5.0 -django_compressor==1.2 -django-social-auth==0.7.20 -hg+https://bitbucket.org/liberation/sesql -Markdown==2.3.1 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..62c656d1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,15 @@ +django-compressor==1.3 +Django==1.5.5 +GenericCache==1.0.2 +httplib2==0.7.7 +oauth2==1.5.211 +oauthlib==0.6.1 +Pillow==2.3.0 +psycopg2==2.5.2 +python-social-auth==0.1.22 +requests-oauthlib==0.4.0 +requests==2.2.1 +simplejson==3.0.7 +South==0.7.6 +django-leaflet-storage==0.5.0 +hg+https://bitbucket.org/liberation/sesql \ No newline at end of file diff --git a/umap/settings/base.py b/umap/settings/base.py index b661b5b9..c3f28086 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -42,7 +42,7 @@ INSTALLED_APPS = ( 'umap', 'sesql', 'compressor', - 'social_auth', + 'social.apps.django_app.default', 'south', @@ -122,7 +122,8 @@ TEMPLATE_DIRS = ( TEMPLATE_CONTEXT_PROCESSORS += ( 'django.core.context_processors.request', - 'social_auth.context_processors.social_auth_backends', + 'social.apps.django_app.context_processors.backends', + 'social.apps.django_app.context_processors.login_redirect', ) #============================================================================== @@ -158,18 +159,19 @@ MAP_SHORT_URL_NAME = "umap_short_url" COMPRESS_ENABLED = True COMPRESS_OFFLINE = True -SOCIAL_AUTH_ASSOCIATE_URL_NAME = "associate_complete" SOCIAL_AUTH_DEFAULT_USERNAME = lambda u: slugify(u) -SOCIAL_AUTH_EXTRA_DATA = False SOCIAL_AUTH_ASSOCIATE_BY_EMAIL = True LOGIN_URL = "login" SOCIAL_AUTH_LOGIN_REDIRECT_URL = "/login/popup/end/" SOCIAL_AUTH_PIPELINE = ( - 'social_auth.backends.pipeline.social.social_auth_user', - 'social_auth.backends.pipeline.associate.associate_by_email', - 'social_auth.backends.pipeline.user.get_username', - 'social_auth.backends.pipeline.user.create_user', - 'social_auth.backends.pipeline.social.associate_user', - 'social_auth.backends.pipeline.social.load_extra_data', - 'social_auth.backends.pipeline.user.update_user_details' -) \ No newline at end of file + 'social.pipeline.social_auth.social_details', + 'social.pipeline.social_auth.social_uid', + 'social.pipeline.social_auth.auth_allowed', + 'social.pipeline.social_auth.social_user', + 'social.pipeline.social_auth.associate_by_email', + 'social.pipeline.user.get_username', + 'social.pipeline.user.create_user', + 'social.pipeline.social_auth.associate_user', + 'social.pipeline.social_auth.load_extra_data', + 'social.pipeline.user.user_details' +) diff --git a/umap/settings/local.py.sample b/umap/settings/local.py.sample index 25e26a6b..c6d10d16 100644 --- a/umap/settings/local.py.sample +++ b/umap/settings/local.py.sample @@ -8,11 +8,14 @@ it to umap/settings/local.py. It should not be checked into your code repository. """ + from umap.settings.base import * # pylint: disable=W0614,W0401 -SECRET_KEY = 'your secret key here' +SECRET_KEY = '' +INTERNAL_IPS = ('127.0.0.1', ) +ALLOWED_HOSTS = ['*', ] -DEBUG = True # False in production +DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( @@ -20,14 +23,6 @@ ADMINS = ( ) MANAGERS = ADMINS -# ALLOWED_HOST required by Django >= 1.5 -# Should be set to your domain name, see: -# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-ALLOWED_HOSTS -# Don't use "*" in production! -ALLOWED_HOSTS = [ - '*', -] - DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', @@ -37,36 +32,48 @@ DATABASES = { WSGI_APPLICATION = 'umap.wsgi.application' -COMPRESS_ENABLED = False # True in production +COMPRESS_ENABLED = False COMPRESS_OFFLINE = True LANGUAGE_CODE = 'en' -LANGUAGES = ( - ('en', 'English'), - ('fr', u'Francais'), - ('it', u'Italiano'), - ('pt', u'Portuguese'), - ('nl', u'Dutch'), -) AUTHENTICATION_BACKENDS = ( - 'social_auth.backends.contrib.github.GithubBackend', - 'social_auth.backends.contrib.bitbucket.BitbucketBackend', - 'social_auth.backends.twitter.TwitterBackend', - 'umap.osm_backend.OSMBackend', + 'social.backends.github.GithubOAuth2', + 'social.backends.bitbucket.BitbucketOAuth', + 'social.backends.twitter.TwitterOAuth', + 'social.backends.openstreetmap.OpenStreetMapOAuth', 'django.contrib.auth.backends.ModelBackend', ) -GITHUB_APP_ID = 'xxx' -GITHUB_API_SECRET = 'xxx' -BITBUCKET_CONSUMER_KEY = 'xxx' -BITBUCKET_CONSUMER_SECRET = 'xxx' +SOCIAL_AUTH_GITHUB_KEY = 'xxx' +SOCIAL_AUTH_GITHUB_SECRET = 'xxx' +SOCIAL_AUTH_BITBUCKET_KEY = 'xxx' +SOCIAL_AUTH_BITBUCKET_SECRET = 'xxx' # We need email to associate with other Oauth providers -GITHUB_AUTH_EXTRA_ARGUMENTS = {"scope": "user:email"} -TWITTER_CONSUMER_KEY = "xxx" -TWITTER_CONSUMER_SECRET = "xxx" -OSM_CONSUMER_KEY = 'xxx' -OSM_CONSUMER_SECRET = 'xxx' -UMAP_DEMO_PK = 34 # Pk of a Map instance +SOCIAL_AUTH_GITHUB_SCOPE = ["user:email", ] +SOCIAL_AUTH_TWITTER_KEY = "xxx" +SOCIAL_AUTH_TWITTER_SECRET = "xxx" +SOCIAL_AUTH_OPENSTREETMAP_KEY = 'xxx' +SOCIAL_AUTH_OPENSTREETMAP_SECRET = 'xxx' +MIDDLEWARE_CLASSES += ( + 'social.apps.django_app.middleware.SocialAuthExceptionMiddleware', +) +SOCIAL_AUTH_RAISE_EXCEPTIONS = False +SOCIAL_AUTH_BACKEND_ERROR_URL = "/" + +# UMAP_DEMO_PK = 204 +# UMAP_SHOWCASE_PK = 1156 LEAFLET_STORAGE_ALLOW_ANONYMOUS = True -UMAP_DEMO_SITE = False +UMAP_DEMO_SITE = True +SITE_URL = "http://localhost:8019" +SHORT_SITE_URL = "http://s.hort" SESQL_CONFIG_PATH = "umap.sesql_config" + +# CACHES = { +# 'default': { +# 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', +# 'LOCATION': '/var/tmp/django_cache', +# } +# } + +# POSTGIS_VERSION = (2, 1, 0) +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/umap/templates/registration/login.html b/umap/templates/registration/login.html index 9093435f..de881055 100644 --- a/umap/templates/registration/login.html +++ b/umap/templates/registration/login.html @@ -4,9 +4,9 @@
diff --git a/umap/urls.py b/umap/urls.py index 3feaa4f3..9ae4ed8c 100644 --- a/umap/urls.py +++ b/umap/urls.py @@ -12,13 +12,14 @@ from . import views admin.autodiscover() -urlpatterns = patterns('', +urlpatterns = patterns( + '', (r'^admin/', include(admin.site.urls)), - url(r'', include('social_auth.urls')), - # We don't want it to be localized + url('', include('social.apps.django_app.urls', namespace='social')), url(r'^m/(?P\d+)/$', MapShortUrl.as_view(), name='umap_short_url'), ) -urlpatterns += i18n_patterns('', +urlpatterns += i18n_patterns( + '', url(r'^$', views.home, name="home"), url(r'^showcase/$', cache_page(24 * 60 * 60)(views.showcase), name='maps_showcase'), url(r'^search/$', views.search, name="search"), @@ -28,6 +29,5 @@ urlpatterns += i18n_patterns('', ) if settings.DEBUG and settings.MEDIA_ROOT: - urlpatterns += static(settings.MEDIA_URL, - document_root=settings.MEDIA_ROOT) + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += staticfiles_urlpatterns()