minimal allauth support
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 9 Mar 2012 13:46:22 +0000 (14:46 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 9 Mar 2012 13:46:22 +0000 (14:46 +0100)
12 files changed:
requirements.txt
wolnelektury/settings.py
wolnelektury/static/css/dialogs.css
wolnelektury/static/img/auth/google-icon.png [new file with mode: 0644]
wolnelektury/static/img/auth/google.png [new file with mode: 0644]
wolnelektury/static/img/auth/openid-large.png?1237615666 [new file with mode: 0644]
wolnelektury/static/img/auth/openid.png [new file with mode: 0644]
wolnelektury/templates/auth/login.html [new file with mode: 0644]
wolnelektury/templates/auth/login_register.html
wolnelektury/templates/socialaccount/snippets/provider_list.html [new file with mode: 0644]
wolnelektury/urls.py
wolnelektury/views.py

index a961c4d..ecb07cc 100644 (file)
@@ -8,6 +8,7 @@ django-rosetta>=0.5.3
 django-maintenancemode>=0.9
 django-piston
 django-jsonfield
+django-allauth
 
 python-memcached
 piwik
index 07b1ef0..7f22b0c 100644 (file)
@@ -92,6 +92,8 @@ TEMPLATE_CONTEXT_PROCESSORS = (
     'django.core.context_processors.request',
     'wolnelektury.context_processors.extra_settings',
     'search.context_processors.search_form',
+    "allauth.context_processors.allauth",
+    "allauth.account.context_processors.account",
 )
 
 MIDDLEWARE_CLASSES = [
@@ -114,6 +116,12 @@ TEMPLATE_DIRS = [
     path.join(PROJECT_DIR, 'templates'),
 ]
 
+
+AUTHENTICATION_BACKENDS = [
+    'django.contrib.auth.backends.ModelBackend',
+    'allauth.account.auth_backends.AuthenticationBackend',
+]
+EMAIL_CONFIRMATION_DAYS = 2
 LOGIN_URL = '/uzytkownicy/zaloguj/'
 
 LOGIN_REDIRECT_URL = '/'
@@ -136,6 +144,16 @@ INSTALLED_APPS = [
     'djkombu',
     #    'django_nose',
 
+    #allauth stuff
+    'emailconfirmation',
+    'uni_form',
+    'allauth',
+    'allauth.account',
+    'allauth.socialaccount',
+    'allauth.openid',
+    #'allauth.facebook',
+    #'allauth.twitter',
+
     # included
     'compress',
     'modeltranslation',
index d83116b..803c14d 100755 (executable)
 #custom-pdf-window label {
     display: inline;
 }
+
+
+.socialauth {
+       margin: 1em 0;
+       padding: 0;
+}
+.socialauth li {
+       display: inline;
+       list-style: none;
+       margin-right: 1em;
+}
diff --git a/wolnelektury/static/img/auth/google-icon.png b/wolnelektury/static/img/auth/google-icon.png
new file mode 100644 (file)
index 0000000..d16d531
Binary files /dev/null and b/wolnelektury/static/img/auth/google-icon.png differ
diff --git a/wolnelektury/static/img/auth/google.png b/wolnelektury/static/img/auth/google.png
new file mode 100644 (file)
index 0000000..bf7d112
Binary files /dev/null and b/wolnelektury/static/img/auth/google.png differ
diff --git a/wolnelektury/static/img/auth/openid-large.png?1237615666 b/wolnelektury/static/img/auth/openid-large.png?1237615666
new file mode 100644 (file)
index 0000000..6094fff
Binary files /dev/null and b/wolnelektury/static/img/auth/openid-large.png?1237615666 differ
diff --git a/wolnelektury/static/img/auth/openid.png b/wolnelektury/static/img/auth/openid.png
new file mode 100644 (file)
index 0000000..83e9769
Binary files /dev/null and b/wolnelektury/static/img/auth/openid.png differ
diff --git a/wolnelektury/templates/auth/login.html b/wolnelektury/templates/auth/login.html
new file mode 100644 (file)
index 0000000..553e873
--- /dev/null
@@ -0,0 +1,14 @@
+{% extends "ajaxable/form.html" %}
+{% load i18n %}
+
+{% block extra %}
+
+<h2>{% trans "or join accounts:" %}</h2>
+
+<ul class="socialauth">
+{% include "socialaccount/snippets/provider_list.html" %}
+</ul>
+
+{% endblock %}
+
+
index ecaeaf4..394902a 100755 (executable)
@@ -3,6 +3,12 @@
 
 {% block extra %}
 
+<h2>{% trans "or join accounts:" %}</h2>
+
+<ul class="socialauth">
+{% include "socialaccount/snippets/provider_list.html" %}
+</ul>
+
 
 <h1>{% trans "or register" %}:</h1>
 
diff --git a/wolnelektury/templates/socialaccount/snippets/provider_list.html b/wolnelektury/templates/socialaccount/snippets/provider_list.html
new file mode 100644 (file)
index 0000000..99e30a5
--- /dev/null
@@ -0,0 +1,21 @@
+{% load allauth_tags %}
+
+{% if allauth.openid_enabled %}
+<li><a title="Google" class="socialaccount_provider google" href="{% openid_login_url openid="https://www.google.com/accounts/o8/id" %}">
+       <img alt="Google" src="{{ STATIC_URL }}img/auth/google.png" /></a></li>
+{% endif %}
+{% if allauth.twitter_enabled %}
+<li><a title="Twitter" class="socialaccount_provider twitter" href="{% twitter_login_url %}">
+       <img alt="Twitter" src="{{ STATIC_URL }}img/auth/twitter.png" /></a></li>
+{% endif %}
+{% if allauth.facebook_enabled %}
+<li><a title="Facebook" class="socialaccount_provider facebook" href="{% facebook_login_url %}">
+       <img alt="Facebook" src="{{ STATIC_URL }}img/auth/facebook.png" /></a></li>
+{% endif %}
+{% if allauth.openid_enabled %}
+<!--li><a title="Yahoo" class="socialaccount_provider yahoo" href="{% openid_login_url openid="http://me.yahoo.com" %}">
+       <img alt="Yahoo" src="{{ STATIC_URL }}img/auth/yahoo.png" /></a></li-->
+<!--li><a title="OpenID" class="socialaccount_provider openid" href="{% openid_login_url %}">
+       <img alt="OpenID" src="{{ STATIC_URL }}img/auth/openid.png" /></a></li-->
+<!--li><a title="Hyves" class="socialaccount_provider hyves" href="{% openid_login_url openid="http://hyves.nl" %}">Hyves</a></li-->
+{% endif %}
index f6cd8d9..3695990 100644 (file)
@@ -32,6 +32,7 @@ urlpatterns += patterns('',
     url(r'^raporty/', include('reporting.urls')),
     url(r'^info/', include('infopages.urls')),
     url(r'^ludzie/', include('social.urls')),
+    url(r'^uzytkownicy/', include('allauth.urls')),
 
     # Admin panel
     url(r'^admin/catalogue/book/import$', 'catalogue.views.import_book', name='import_book'),
index c262479..bcead03 100755 (executable)
@@ -27,6 +27,7 @@ def main_page(request):
 
 class LoginFormView(AjaxableFormView):
     form_class = AuthenticationForm
+    template = "auth/login.html"
     placeholdize = True
     title = _('Sign in')
     submit = _('Sign in')