diff --git a/WikiENS/settings.py b/WikiENS/settings.py index aa03b7b..9c970f5 100644 --- a/WikiENS/settings.py +++ b/WikiENS/settings.py @@ -41,10 +41,13 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'django.contrib.sites', 'django.contrib.humanize', + 'django_nyt', 'mptt', 'sekizai', 'sorl.thumbnail', + 'widget_tweaks', + 'shared', # Do not move, so templates in `shared` can override # thoses in `wiki` 'wiki', @@ -52,6 +55,12 @@ INSTALLED_APPS = [ 'wiki.plugins.notifications', 'wiki.plugins.images', 'wiki.plugins.macros', + + 'allauth_ens', + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + 'allauth_ens.providers.clipper', ] MIDDLEWARE = [ @@ -137,12 +146,35 @@ USE_TZ = True STATIC_URL = '/static/' -LOGIN_REDIRECT_URL = reverse_lazy('wiki:get', kwargs={'path': ''}) + +# Email +# https://docs.djangoproject.com/en/1.11/topics/email/ + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + + +# Authentication +# https://docs.djangoproject.com/en/1.11/ref/settings/#auth +# https://django-allauth.readthedocs.io/en/latest/index.html + +AUTHENTICATION_BACKENDS = [ + 'allauth.account.auth_backends.AuthenticationBackend', +] + +HOME_URL = reverse_lazy('wiki:root') + +LOGIN_URL = '_profil/login/' +LOGIN_REDIRECT_URL = HOME_URL +ACCOUNT_LOGOUT_REDIRECT_URL = HOME_URL + +ACCOUNT_AUTHENTICATED_LOGIN_REDIRECTS = False +ACCOUNT_HOME_URL = HOME_URL +ACCOUNT_USER_DISPLAY = lambda u: u.get_full_name() or u.username # WIKI SETTINGS -# Sign up, login and logout views should be accessible -WIKI_ACCOUNT_HANDLING = True +# Use sign up, login, logout, profile settings views of allauth. +WIKI_ACCOUNT_HANDLING = False # Signup allowed? If it’s not allowed, logged in superusers # can still access the signup page to create new users. diff --git a/WikiENS/urls.py b/WikiENS/urls.py index 17a08d3..12f7bec 100644 --- a/WikiENS/urls.py +++ b/WikiENS/urls.py @@ -1,15 +1,20 @@ from django.conf.urls import url, include from django.contrib import admin -from django.views.generic import RedirectView -from django.urls import reverse_lazy +from allauth_ens.views import capture_login, capture_logout from wiki.urls import get_pattern as get_wiki_pattern from django_nyt.urls import get_pattern as get_nyt_pattern -redirect_home_view = RedirectView.as_view(url=reverse_lazy('home')) +allauth_urls = [ + # Catch login/logout views of admin site. + url(r'^_admin/login/$', capture_login), + url(r'^_admin/logout/$', capture_logout), + # Allauth urls. + url(r'^_profil/', include('allauth.urls')), +] -urlpatterns = [ - url(r'^admin/', admin.site.urls), +urlpatterns = allauth_urls + [ + url(r'^_admin/', admin.site.urls), url(r'^notifications/', get_nyt_pattern()), url(r'', get_wiki_pattern()), ] diff --git a/requirement.txt b/requirement.txt index c5f6efc..fed7026 100644 --- a/requirement.txt +++ b/requirement.txt @@ -11,4 +11,4 @@ Pillow==4.2.1 six==1.10.0 sorl-thumbnail==12.3 wiki==0.2.4 -django-allauth-ens==0.0.1.dev0 +django-allauth-ens==0.0.1.dev1 diff --git a/shared/templates/wiki/base.html b/shared/templates/wiki/base.html index 3bbddaa..b5e5a6c 100644 --- a/shared/templates/wiki/base.html +++ b/shared/templates/wiki/base.html @@ -1,6 +1,6 @@ {% extends "wiki/base_site.html" %} +{% load i18n staticfiles %} {% load sekizai_tags %} -{% load staticfiles %} {% block wiki_site_title %} - WikiENS{% endblock %} @@ -12,6 +12,50 @@
+ + {% endblock %} {% block wiki_footer_logo %}