delete addtoblock and renderblock tags (#25361)
This commit is contained in:
parent
ddcabf6372
commit
cecdc9adfd
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "authentic2/base-page.html" %}
|
||||
{% load i18n authentic2 gadjo %}
|
||||
{% load i18n gadjo %}
|
||||
|
||||
{% block page-title %}
|
||||
{{ block.super }} - {{ title }}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "authentic2/base-page.html" %}
|
||||
{% load i18n gadjo authentic2 staticfiles %}
|
||||
{% load i18n gadjo staticfiles %}
|
||||
|
||||
{% block gadjo-jquery %}{% endblock %}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load i18n authentic2 staticfiles %}
|
||||
{% load i18n staticfiles %}
|
||||
<div>
|
||||
<form method="post" action="">
|
||||
{% csrf_token %}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "authentic2/base-page.html" %}
|
||||
{% load i18n authentic2 gadjo %}
|
||||
{% load i18n gadjo %}
|
||||
|
||||
{% block extrascripts %}
|
||||
{{ block.super }}
|
||||
|
|
|
@ -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 ''
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue