diff --git a/README.rst b/README.rst index 03d81a06..af84f10b 100644 --- a/README.rst +++ b/README.rst @@ -40,6 +40,23 @@ Add database connexion informations in `local.py`, for example:: } } +uMap uses `django-social-auth `_ for user authentication. So you will need to configure it according to your +needs. For example:: + + AUTHENTICATION_BACKENDS = ( + 'social_auth.backends.contrib.github.GithubBackend', + 'social_auth.backends.contrib.bitbucket.BitbucketBackend', + 'social_auth.backends.twitter.TwitterBackend', + 'django.contrib.auth.backends.ModelBackend', + ) + GITHUB_APP_ID = 'xxx' + GITHUB_API_SECRET = 'zzz' + BITBUCKET_CONSUMER_KEY = 'xxx' + BITBUCKET_CONSUMER_SECRET = 'zzz' + TWITTER_CONSUMER_KEY = "xxx" + TWITTER_CONSUMER_SECRET = "yyy" + + Create the tables:: python manage.py syncdb --migrate @@ -56,4 +73,3 @@ Go to the admin (http://localhost:8000/admin/) and add: - almost one licence - almost one tilelayer -- maybe some users to play with diff --git a/requirements.pip b/requirements.pip index adf5870f..ea486af0 100644 --- a/requirements.pip +++ b/requirements.pip @@ -9,6 +9,7 @@ south django-leaflet-storage django_compressor django-foundation +django-social-auth git+git://github.com/yohanboniface/vectorformats.git@leafletstorage git+git://github.com/frankban/django-endless-pagination.git 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 b084a8d5..9602ee39 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -3,6 +3,7 @@ """Base settings shared by all environments""" # Import global settings to make it easier to extend settings. from django.conf.global_settings import * # pylint: disable=W0614,W0401 +from django.template.defaultfilters import slugify #============================================================================== # Generic Django project settings @@ -34,6 +35,7 @@ INSTALLED_APPS = ( 'umap', 'sesql', 'compressor', + 'social_auth', 'south', @@ -113,6 +115,7 @@ TEMPLATE_DIRS = ( TEMPLATE_CONTEXT_PROCESSORS += ( 'django.core.context_processors.request', + 'social_auth.context_processors.social_auth_backends', ) #============================================================================== @@ -139,3 +142,19 @@ AUTHENTICATION_BACKENDS += ( #============================================================================== 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' +) diff --git a/umap/static/umap/bitbucket.png b/umap/static/umap/bitbucket.png new file mode 100644 index 00000000..32863151 Binary files /dev/null and b/umap/static/umap/bitbucket.png differ diff --git a/umap/static/umap/github.png b/umap/static/umap/github.png new file mode 100644 index 00000000..b9b32621 Binary files /dev/null and b/umap/static/umap/github.png differ diff --git a/umap/static/umap/twitter.png b/umap/static/umap/twitter.png new file mode 100644 index 00000000..237c5d1f Binary files /dev/null and b/umap/static/umap/twitter.png differ diff --git a/umap/static/umap/umap.css b/umap/static/umap/umap.css index 0e6b9930..32bb1676 100644 --- a/umap/static/umap/umap.css +++ b/umap/static/umap/umap.css @@ -87,4 +87,32 @@ input:-moz-placeholder, :-moz-placeholder { height: 16px; margin-right: 10px; border: 1px solid #000; +} + +/* **************** */ +/* Login icons */ +/* **************** */ +/*.login-grid li { +} +*/ +.login-grid a { + border: 1px solid #e5e5e5; + padding: 5px; + color: #000; + background-position: center bottom; + background-repeat: no-repeat; + background-size: 92px 92px; + height: 92px; + width: 92px; + display: inline-block; + margin-right: 10px; +} +.login-grid .login-github { + background-image: url("./github.png"); +} +.login-grid .login-bitbucket { + background-image: url("./bitbucket.png"); +} +.login-grid .login-twitter { + background-image: url("./twitter.png"); } \ No newline at end of file diff --git a/umap/templates/registration/login.html b/umap/templates/registration/login.html new file mode 100644 index 00000000..b818aa68 --- /dev/null +++ b/umap/templates/registration/login.html @@ -0,0 +1,14 @@ +{% load i18n %} +{% load url from future %} + +
{% trans "Please choose a provider" %}
+ +
+ +
diff --git a/umap/templates/umap/home.html b/umap/templates/umap/home.html index 39f8da4e..5b51a6d8 100644 --- a/umap/templates/umap/home.html +++ b/umap/templates/umap/home.html @@ -68,11 +68,14 @@ {% trans "Fork it" %} -
-

- {% trans "Users to play with" %} (password: 123123): {% for u in users %}{{ u }}{% if not forloop.last %}, {% endif %}{% endfor %} -

+ + {% if not user.is_authenticated %} + + {% endif %}
diff --git a/umap/urls.py b/umap/urls.py index e0904510..96519d60 100644 --- a/umap/urls.py +++ b/umap/urls.py @@ -15,6 +15,7 @@ urlpatterns = patterns('', url(r'^$', views.home, name="home"), url(r'^search/$', views.search, name="search"), url(r'^user/(?P[-_\w]+)/$', views.user_maps, name='user_maps'), + url(r'', include('social_auth.urls')), (r'', include('leaflet_storage.urls')), )