Permalink
Browse files

Dropped _tags postfix from template tag libraries

  • Loading branch information...
1 parent e7730b5 commit 2aa4cef08906dcaf4a29c5186fefda5339bb1c00 @pennersr committed Aug 24, 2012
View
@@ -1,3 +1,9 @@
+2012-08-24 Raymond Penners <raymond.penners@intenct.nl>
+
+ * account/socialaccount: Dropped the _tags postfix from the
+ template tag libraries. Simply use {% load account %} and {% load
+ socialaccount %}.
+
2012-08-21 Raymond Penners <raymond.penners@intenct.nl>
* Added signup and social login signals.
View
@@ -230,6 +230,14 @@ EMAIL_CONFIRMATION_DAYS (=# of days, no default)
Upgrading
---------
+From 0.7.0
+**********
+
+- `{% load account_tags %}` is deprecated, simply use: `{% load account %}`
+
+- `{% load socialaccount_tags %}` is deprecated, simply use:
+ `{% load socialaccount %}`
+
From 0.5.0
**********
@@ -306,12 +314,12 @@ everybody's cup of tea.
To initiate a login use::
- {% load socialaccount_tags %}
+ {% load socialaccount %}
<a href="{% provider_login_url "facebook" method="js_sdk" %}">Facebook Connect</a>
or::
- {% load socialaccount_tags %}
+ {% load socialaccount %}
<a href="{% provider_login_url "facebook" method="oauth2" %}">Facebook OAuth2</a>
The following Facebook settings are available::
@@ -382,7 +390,7 @@ follows::
If you want to manually include login links yourself, you can use the
following template tag::
- {% load socialaccount_tags %}
+ {% load socialaccount %}
<a href="{% provider_login_url "openid" openid="https://www.google.com/accounts/o8/id" next="/success/url/" %}">Google</a>
@@ -426,9 +434,9 @@ Template Tags
The following template tag libraries are available:
-- `account_tags`: tags for dealing with accounts in general
+- `account`: tags for dealing with accounts in general
-- `socialaccount_tags`: tags focused on social accounts
+- `socialaccount`: tags focused on social accounts
Account Tags
@@ -438,13 +446,13 @@ Use `user_display` to render a user name without making assumptions on
how the user is represented (e.g. render the username, or first
name?)::
- {% load account_tags %}
+ {% load account %}
{% user_display user %}
Or, if you need to use in a `{% blocktrans %}`::
- {% load account_tags %}
+ {% load account %}
{% user_display user as user_display}
{% blocktrans %}{{ user_display }} has logged in...{% endblocktrans %}
@@ -458,7 +466,7 @@ Social Account Tags
Use the `provider_login_url` tag to generate provider specific login URLs::
- {% load socialaccount_tags %}
+ {% load socialaccount %}
<a href="{% provider_login_url "openid" openid="https://www.google.com/accounts/o8/id" next="/success/url/" %}">Google</a>
<a href="{% provider_login_url "twitter" %}">Twitter</a>
@@ -0,0 +1,47 @@
+from django import template
+
+from allauth.account.utils import user_display
+
+register = template.Library()
+
+class UserDisplayNode(template.Node):
+
+ def __init__(self, user, as_var=None):
+ self.user_var = template.Variable(user)
+ self.as_var = as_var
+
+ def render(self, context):
+ user = self.user_var.resolve(context)
+
+ display = user_display(user)
+
+ if self.as_var:
+ context[self.as_var] = display
+ return ""
+ return display
+
+
+@register.tag(name="user_display")
+def do_user_display(parser, token):
+ """
+ Example usage::
+
+ {% user_display user %}
+
+ or if you need to use in a {% blocktrans %}::
+
+ {% user_display user as user_display %}
+ {% blocktrans %}{{ user_display }} has sent you a gift.{% endblocktrans %}
+
+ """
+ bits = token.split_contents()
+ if len(bits) == 2:
+ user = bits[1]
+ as_var = None
+ elif len(bits) == 4:
+ user = bits[1]
+ as_var = bits[3]
+ else:
+ raise template.TemplateSyntaxError("'%s' takes either two or four arguments" % bits[0])
+
+ return UserDisplayNode(user, as_var)
@@ -1,47 +1,6 @@
-from django import template
+import warnings
-from allauth.account.utils import user_display
+warnings.warn("{% load account_tags %} is deprecated, use {% load account %}",
+ DeprecationWarning)
-register = template.Library()
-
-class UserDisplayNode(template.Node):
-
- def __init__(self, user, as_var=None):
- self.user_var = template.Variable(user)
- self.as_var = as_var
-
- def render(self, context):
- user = self.user_var.resolve(context)
-
- display = user_display(user)
-
- if self.as_var:
- context[self.as_var] = display
- return ""
- return display
-
-
-@register.tag(name="user_display")
-def do_user_display(parser, token):
- """
- Example usage::
-
- {% user_display user %}
-
- or if you need to use in a {% blocktrans %}::
-
- {% user_display user as user_display %}
- {% blocktrans %}{{ user_display }} has sent you a gift.{% endblocktrans %}
-
- """
- bits = token.split_contents()
- if len(bits) == 2:
- user = bits[1]
- as_var = None
- elif len(bits) == 4:
- user = bits[1]
- as_var = bits[3]
- else:
- raise template.TemplateSyntaxError("'%s' takes either two or four arguments" % bits[0])
-
- return UserDisplayNode(user, as_var)
+from account import *
@@ -0,0 +1,49 @@
+from django.template.defaulttags import token_kwargs
+from django import template
+
+from allauth.socialaccount import providers
+
+register = template.Library()
+
+class ProviderLoginURLNode(template.Node):
+ def __init__(self, provider_id, params):
+ self.provider_id_var = template.Variable(provider_id)
+ self.params = params
+
+ def render(self, context):
+ provider_id = self.provider_id_var.resolve(context)
+ provider = providers.registry.by_id(provider_id)
+ query = dict([(name, var.resolve(context)) for name, var
+ in self.params.iteritems()])
+ request = context['request']
+ if not query.has_key('next'):
+ next = request.REQUEST.get('next')
+ if next:
+ query['next'] = next
+ else:
+ if not query['next']:
+ del query['next']
+ return provider.get_login_url(request, **query)
+
+@register.tag
+def provider_login_url(parser, token):
+ """
+ {% provider_login_url "facebook" next=bla %}
+ {% provider_login_url "openid" openid="http://me.yahoo.com" next=bla %}
+ """
+ bits = token.split_contents()
+ provider_id = bits[1]
+ params = token_kwargs(bits[2:], parser, support_legacy=False)
+ return ProviderLoginURLNode(provider_id, params)
+
+class ProvidersMediaJSNode(template.Node):
+ def render(self, context):
+ request = context['request']
+ ret = '\n'.join([p.media_js(request)
+ for p in providers.registry.get_list()])
+ return ret
+
+
+@register.tag
+def providers_media_js(parser, token):
+ return ProvidersMediaJSNode()
@@ -1,49 +1,6 @@
-from django.template.defaulttags import token_kwargs
-from django import template
+import warnings
-from allauth.socialaccount import providers
+warnings.warn("{% load socialaccount_tags %} is deprecated, use"
+ " {% load socialaccount %}", DeprecationWarning)
-register = template.Library()
-
-class ProviderLoginURLNode(template.Node):
- def __init__(self, provider_id, params):
- self.provider_id_var = template.Variable(provider_id)
- self.params = params
-
- def render(self, context):
- provider_id = self.provider_id_var.resolve(context)
- provider = providers.registry.by_id(provider_id)
- query = dict([(name, var.resolve(context)) for name, var
- in self.params.iteritems()])
- request = context['request']
- if not query.has_key('next'):
- next = request.REQUEST.get('next')
- if next:
- query['next'] = next
- else:
- if not query['next']:
- del query['next']
- return provider.get_login_url(request, **query)
-
-@register.tag
-def provider_login_url(parser, token):
- """
- {% provider_login_url "facebook" next=bla %}
- {% provider_login_url "openid" openid="http://me.yahoo.com" next=bla %}
- """
- bits = token.split_contents()
- provider_id = bits[1]
- params = token_kwargs(bits[2:], parser, support_legacy=False)
- return ProviderLoginURLNode(provider_id, params)
-
-class ProvidersMediaJSNode(template.Node):
- def render(self, context):
- request = context['request']
- ret = '\n'.join([p.media_js(request)
- for p in providers.registry.get_list()])
- return ret
-
-
-@register.tag
-def providers_media_js(parser, token):
- return ProvidersMediaJSNode()
+from socialaccount import *
@@ -1,7 +1,7 @@
{% extends "account/base.html" %}
{% load i18n %}
-{% load account_tags %}
+{% load account %}
{% load url from future %}
{% block head_title %}{% trans "Sign In" %}{% endblock %}
@@ -1,7 +1,7 @@
{% extends "account/base.html" %}
{% load i18n %}
-{% load account_tags %}
+{% load account %}
{% block head_title %}{% trans "Password Reset" %}{% endblock %}
@@ -1,7 +1,7 @@
{% extends "account/base.html" %}
{% load i18n %}
-{% load account_tags %}
+{% load account %}
{% block head_title %}{% trans "Password Reset" %}{% endblock %}
@@ -1,5 +1,5 @@
{% load i18n %}
-{% load account_tags %}
+{% load account %}
{% user_display user as user_display %}
<p><strong>{% trans "Note" %}:</strong> {% blocktrans %}you are already logged in as {{ user_display }}.{% endblocktrans %}</p>
@@ -1,7 +1,7 @@
{% extends "account/base.html" %}
{% load i18n %}
-{% load account_tags %}
+{% load account %}
{% block head_title %}{% trans "E-mail Address Confirmation" %}{% endblock %}
@@ -1,4 +1,4 @@
-{% load socialaccount_tags %}
+{% load socialaccount %}
{% providers_media_js %}
@@ -1,4 +1,4 @@
-{% load socialaccount_tags %}
+{% load socialaccount %}
{% for provider in socialaccount.providers %}
{% if provider.id == "openid" %}
@@ -3,7 +3,7 @@
{% load url from future %}
{% load i18n %}
{% load bootstrap %}
-{% load account_tags %}
+{% load account %}
{% block head_title %}{% trans "Sign In" %}{% endblock %}
@@ -2,7 +2,7 @@
{% load i18n %}
{% load bootstrap %}
-{% load account_tags %}
+{% load account %}
{% block head_title %}{% trans "Password Reset" %}{% endblock %}
@@ -3,7 +3,7 @@
{% load url from future %}
{% load i18n %}
{% load uni_form_tags %}
-{% load account_tags %}
+{% load account %}
{% block head_title %}{% trans "Sign In" %}{% endblock %}
@@ -2,7 +2,7 @@
{% load i18n %}
{% load uni_form_tags %}
-{% load account_tags %}
+{% load account %}
{% block head_title %}{% trans "Password Reset" %}{% endblock %}

0 comments on commit 2aa4cef

Please sign in to comment.