diff --git a/allauth/app_settings.py b/allauth/app_settings.py index 6084bc6744..eb631485ef 100644 --- a/allauth/app_settings.py +++ b/allauth/app_settings.py @@ -1,40 +1,7 @@ -import django from django.conf import settings -from django.core.exceptions import ImproperlyConfigured -from django import template SOCIALACCOUNT_ENABLED = 'allauth.socialaccount' in settings.INSTALLED_APPS - -def check_context_processors(): - allauth_ctx = 'allauth.socialaccount.context_processors.socialaccount' - ctx_present = False - - if django.VERSION < (1, 8,): - setting = "settings.TEMPLATE_CONTEXT_PROCESSORS" - if allauth_ctx in settings.TEMPLATE_CONTEXT_PROCESSORS: - ctx_present = True - else: - for name, engine in template.engines.templates.items(): - if allauth_ctx in engine.get('OPTIONS', {})\ - .get('context_processors', []): - ctx_present = True - else: - setting = "settings.TEMPLATES['{}']['OPTIONS']['context_processors']" - setting = setting.format(name) - - if not ctx_present: - excmsg = ("socialaccount context processor " - "not found in {}. " - "See settings.py instructions here: " - "http://django-allauth.readthedocs.org/en/latest/installation.html") - raise ImproperlyConfigured(excmsg.format(setting)) - - -if SOCIALACCOUNT_ENABLED: - check_context_processors() - - LOGIN_REDIRECT_URL = getattr(settings, 'LOGIN_REDIRECT_URL', '/') USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User') diff --git a/allauth/socialaccount/context_processors.py b/allauth/socialaccount/context_processors.py deleted file mode 100644 index 55d1182f31..0000000000 --- a/allauth/socialaccount/context_processors.py +++ /dev/null @@ -1,5 +0,0 @@ -from . import providers - -def socialaccount(request): - ctx = { 'providers': providers.registry.get_list() } - return dict(socialaccount=ctx) diff --git a/allauth/socialaccount/templatetags/socialaccount.py b/allauth/socialaccount/templatetags/socialaccount.py index 6b8c665b6a..b5de9da129 100644 --- a/allauth/socialaccount/templatetags/socialaccount.py +++ b/allauth/socialaccount/templatetags/socialaccount.py @@ -78,3 +78,16 @@ def get_social_accounts(user): providers = accounts.setdefault(account.provider, []) providers.append(account) return accounts + + +@register.assignment_tag +def get_providers(): + """ + Returns a list of social authentication providers. + + Usage: `{% get_providers as socialaccount_providers %}`. + + Then within the template context, `socialaccount_providers` will hold + a list of social providers configured for the current site. + """ + return providers.registry.get_list() diff --git a/allauth/templates/account/login.html b/allauth/templates/account/login.html index 13d4e61754..17bc3a6a40 100644 --- a/allauth/templates/account/login.html +++ b/allauth/templates/account/login.html @@ -1,7 +1,7 @@ {% extends "account/base.html" %} {% load i18n %} -{% load account %} +{% load account socialaccount %} {% block head_title %}{% trans "Sign In" %}{% endblock %} @@ -9,7 +9,9 @@
{% blocktrans with site.name as site_name %}Please sign in with one of your existing third party accounts. Or, sign up for a {{ site_name }} account and sign in below:{% endblocktrans %}
diff --git a/allauth/templates/socialaccount/snippets/provider_list.html b/allauth/templates/socialaccount/snippets/provider_list.html index f65d276fc6..a5e3b02702 100644 --- a/allauth/templates/socialaccount/snippets/provider_list.html +++ b/allauth/templates/socialaccount/snippets/provider_list.html @@ -1,6 +1,8 @@ {% load socialaccount %} -{% for provider in socialaccount.providers %} +{% get_providers as socialaccount_providers %} + +{% for provider in socialaccount_providers %} {% if provider.id == "openid" %} {% for brand in provider.get_brands %}