From 5f979ba5e88dafc6de52b652c1168049017de620 Mon Sep 17 00:00:00 2001 From: Emmanuel Cazenave Date: Thu, 19 Jul 2018 11:24:35 +0200 Subject: [PATCH] delete addtoblock and renderblock tags (#25361) --- src/authentic2/context_processors.py | 1 - src/authentic2/registration_backend/views.py | 1 - .../saml/templates/saml/post_form.html | 2 +- .../templates/authentic2/login.html | 2 +- .../authentic2/login_password_form.html | 2 +- src/authentic2/templates/error.html | 2 +- src/authentic2/templatetags/__init__.py | 0 src/authentic2/templatetags/authentic2.py | 39 ------------------- src/authentic2/views.py | 2 - 9 files changed, 4 insertions(+), 47 deletions(-) delete mode 100644 src/authentic2/templatetags/__init__.py delete mode 100644 src/authentic2/templatetags/authentic2.py diff --git a/src/authentic2/context_processors.py b/src/authentic2/context_processors.py index e2152da1..f4529ddb 100644 --- a/src/authentic2/context_processors.py +++ b/src/authentic2/context_processors.py @@ -40,7 +40,6 @@ def a2_processor(request): else: __AUTHENTIC2_DISTRIBUTION = str(get_distribution('authentic2')) variables['AUTHENTIC2_VERSION'] = __AUTHENTIC2_DISTRIBUTION - variables['add_to_blocks'] = defaultdict(lambda:[]) if hasattr(request, 'session'): variables['LAST_LOGIN'] = request.session.get(constants.LAST_LOGIN_SESSION_KEY) variables['USER_SWITCHED'] = constants.SWITCH_USER_SESSION_KEY in request.session diff --git a/src/authentic2/registration_backend/views.py b/src/authentic2/registration_backend/views.py index ef6699b3..838c5382 100644 --- a/src/authentic2/registration_backend/views.py +++ b/src/authentic2/registration_backend/views.py @@ -95,7 +95,6 @@ class BaseRegistrationView(FormView): ctx = super(BaseRegistrationView, self).get_context_data(**kwargs) request_context = RequestContext(self.request) request_context.push(ctx) - request_context['add_to_blocks'] = collections.defaultdict(lambda: []) parameters = {'request': self.request, 'context_instance': request_context} blocks = [utils.get_backend_method(backend, 'registration', parameters) diff --git a/src/authentic2/saml/templates/saml/post_form.html b/src/authentic2/saml/templates/saml/post_form.html index e1339a18..250abd29 100644 --- a/src/authentic2/saml/templates/saml/post_form.html +++ b/src/authentic2/saml/templates/saml/post_form.html @@ -1,5 +1,5 @@ {% extends "authentic2/base-page.html" %} -{% load i18n authentic2 gadjo %} +{% load i18n gadjo %} {% block page-title %} {{ block.super }} - {{ title }} diff --git a/src/authentic2/templates/authentic2/login.html b/src/authentic2/templates/authentic2/login.html index 60ec19ff..6fadcd0d 100644 --- a/src/authentic2/templates/authentic2/login.html +++ b/src/authentic2/templates/authentic2/login.html @@ -1,5 +1,5 @@ {% extends "authentic2/base-page.html" %} -{% load i18n gadjo authentic2 staticfiles %} +{% load i18n gadjo staticfiles %} {% block gadjo-jquery %}{% endblock %} diff --git a/src/authentic2/templates/authentic2/login_password_form.html b/src/authentic2/templates/authentic2/login_password_form.html index 4b59d088..f3e9b0d2 100644 --- a/src/authentic2/templates/authentic2/login_password_form.html +++ b/src/authentic2/templates/authentic2/login_password_form.html @@ -1,4 +1,4 @@ -{% load i18n authentic2 staticfiles %} +{% load i18n staticfiles %}
{% csrf_token %} diff --git a/src/authentic2/templates/error.html b/src/authentic2/templates/error.html index 7f22470a..300f665e 100644 --- a/src/authentic2/templates/error.html +++ b/src/authentic2/templates/error.html @@ -1,5 +1,5 @@ {% extends "authentic2/base-page.html" %} -{% load i18n authentic2 gadjo %} +{% load i18n gadjo %} {% block extrascripts %} {{ block.super }} diff --git a/src/authentic2/templatetags/__init__.py b/src/authentic2/templatetags/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/authentic2/templatetags/authentic2.py b/src/authentic2/templatetags/authentic2.py deleted file mode 100644 index 12be5c32..00000000 --- a/src/authentic2/templatetags/authentic2.py +++ /dev/null @@ -1,39 +0,0 @@ -from django import template - -register = template.Library() - - -@register.tag('addtoblock') -def addtoblock(parser, token): - try: - tag_name, block_name = token.split_contents() - except ValueError: - raise template.TemplateSyntaxError( - '%r tag requires a single argument' % token.contents.split()[0]) - if not (block_name[0] == block_name[-1] and block_name[0] in ('"', "'")): - raise template.TemplateSyntaxError( - '%r tag requireds its argument to be quoted' % tag_name) - nodelist = parser.parse(('endaddtoblock',)) - parser.delete_first_token() - return AddToBlock(block_name, nodelist) - - -class AddToBlock(template.Node): - def __init__(self, block_name, nodelist): - self.block_name = block_name[1:-1] - self.nodelist = nodelist - - def render(self, context): - output = self.nodelist.render(context) - dest = context['add_to_blocks'][self.block_name] - if output not in dest: - dest.append(output) - return '' - - -@register.simple_tag(takes_context=True) -def renderblock(context, block_name): - if 'add_to_blocks' in context and block_name in context['add_to_blocks']: - return u'\n'.join(context['add_to_blocks'][block_name]) - else: - return '' diff --git a/src/authentic2/views.py b/src/authentic2/views.py index e5f5e7bb..91eb3646 100644 --- a/src/authentic2/views.py +++ b/src/authentic2/views.py @@ -296,7 +296,6 @@ def login(request, template_name='authentic2/login.html', 'registration_authorized': getattr(settings, 'REGISTRATION_OPEN', True), 'registration_url': registration_url, }) - context_instance['add_to_blocks'] = collections.defaultdict(lambda: []) # Cancel button if request.method == "POST" \ @@ -411,7 +410,6 @@ class ProfileView(cbv.TemplateNamesMixin, TemplateView): request = self.request context_instance = RequestContext(request, ctx) - context_instance['add_to_blocks'] = collections.defaultdict(lambda: []) if request.method == "POST": for frontend in frontends: if 'submit-%s' % frontend.id in request.POST: -- 2.18.0