diff --git a/allauth_ens/providers/clipper/provider.py b/allauth_ens/providers/clipper/provider.py index e60a2db..8898dcc 100644 --- a/allauth_ens/providers/clipper/provider.py +++ b/allauth_ens/providers/clipper/provider.py @@ -35,6 +35,7 @@ class ClipperProvider(CASProvider): def extract_extra_data(self, data): extra = super(ClipperProvider, self).extract_extra_data(data) + extra['username'] = data[0] extra['email'] = self.extract_email(data) return extra diff --git a/allauth_ens/templatetags/allauth_ens.py b/allauth_ens/templatetags/allauth_ens.py new file mode 100644 index 0000000..b8aaac1 --- /dev/null +++ b/allauth_ens/templatetags/allauth_ens.py @@ -0,0 +1,24 @@ +import django +from django import template +from django.conf import settings +from django.urls import reverse + + +register = template.Library() + +if django.VERSION >= (1, 9): + simple_tag = register.simple_tag +else: + simple_tag = register.assignment_tag + + +@simple_tag +def get_home_url(): + home_url = getattr(settings, 'ACCOUNT_HOME_URL', None) + return reverse(home_url) if home_url is not None else '/' + + +@simple_tag +def get_profile_url(): + profile_url = getattr(settings, 'ACCOUNT_DETAILS_URL', None) + return reverse(profile_url) if profile_url is not None else '/' diff --git a/allauth_ens/templatetags/allauth_ens_social.py b/allauth_ens/templatetags/allauth_ens_social.py index 001f070..faf2425 100644 --- a/allauth_ens/templatetags/allauth_ens_social.py +++ b/allauth_ens/templatetags/allauth_ens_social.py @@ -1,6 +1,9 @@ +from collections import OrderedDict + import django from django import template +from allauth import app_settings as allauth_settings from allauth.socialaccount.templatetags import socialaccount as tt_social @@ -13,16 +16,18 @@ else: @simple_tag -def get_providers_with_accounts(user): +def is_socialaccount_enabled(): + return allauth_settings.SOCIALACCOUNT_ENABLED and tt_social.get_providers() + + +@simple_tag +def get_accounts_by_providers(user): providers = tt_social.get_providers() accounts = tt_social.get_social_accounts(user) - providers_with_accounts = [ - { - 'provider': provider, - 'accounts': accounts.get(provider.id, []), - } + providers_with_accounts = OrderedDict( + (provider, accounts.get(provider.id, [])) for provider in providers - ] + ) return providers_with_accounts diff --git a/allauth_ens/urls.py b/allauth_ens/urls.py index 6c81cf5..2b37010 100644 --- a/allauth_ens/urls.py +++ b/allauth_ens/urls.py @@ -1,8 +1,3 @@ -from django.conf.urls import include, url -from . import views +from allauth.urls import urlpatterns as allauth_urlpatterns -urlpatterns = [ - url(r'^settings/$', views.account_settings, - name="account_settings"), - url(r'^', include('allauth.urls')), -] +urlpatterns = allauth_urlpatterns diff --git a/allauth_ens/views.py b/allauth_ens/views.py index 3588c25..7e04922 100644 --- a/allauth_ens/views.py +++ b/allauth_ens/views.py @@ -1,11 +1,18 @@ -from django.contrib.auth.decorators import login_required -from django.utils.decorators import method_decorator -from django.views.generic import TemplateView +from django.core.urlresolvers import reverse_lazy +from django.views.generic import RedirectView -@method_decorator(login_required, name="dispatch") -class SettingsAccount(TemplateView): - template_name = 'account/settings.html' +class CaptureLogin(RedirectView): + url = reverse_lazy('account_login') + query_string = True -account_settings = SettingsAccount.as_view() +capture_login = CaptureLogin.as_view() + + +class CaptureLogout(RedirectView): + url = reverse_lazy('account_logout') + query_string = True + + +capture_logout = CaptureLogout.as_view()