remove use of context_instance (fixes #25532)
context_instance is not passed anymore by authentic2, and giving context_instance=None to render() prevent the request object to be feed in the context of the template, breaking some templates.
This commit is contained in:
parent
681dcf3862
commit
9b8e493ded
|
@ -1,6 +1,5 @@
|
|||
from django.utils.translation import gettext_noop
|
||||
from django.template.loader import render_to_string
|
||||
from django.template import RequestContext
|
||||
from django.shortcuts import render
|
||||
|
||||
from authentic2 import app_settings as a2_app_settings
|
||||
|
@ -21,33 +20,33 @@ class FcFrontend(object):
|
|||
def login(self, request, *args, **kwargs):
|
||||
if 'nofc' in request.GET:
|
||||
return
|
||||
tpl_parameters = {'about_url': app_settings.about_url}
|
||||
context = kwargs.pop('context', {}).copy()
|
||||
context['about_url'] = app_settings.about_url
|
||||
if 'fc_user_info' in request.session:
|
||||
tpl_parameters['fc_user_info'] = request.session['fc_user_info']
|
||||
context_instance = kwargs.pop('context_instance', None)
|
||||
return render(request, 'authentic2_auth_fc/login.html',
|
||||
tpl_parameters, context_instance=context_instance)
|
||||
context['fc_user_info'] = request.session['fc_user_info']
|
||||
return render(request, 'authentic2_auth_fc/login.html', context)
|
||||
|
||||
def profile(self, request, *args, **kwargs):
|
||||
unlink = False
|
||||
# We prevent unlinking if the user has no usable password and can't change it
|
||||
# because we assume that the password is the unique other mean of authentication
|
||||
# and unlinking would make the account unreachable.
|
||||
if request.user.has_usable_password() or \
|
||||
a2_app_settings.A2_REGISTRATION_CAN_CHANGE_PASSWORD:
|
||||
# Hide the link to the unlinking view.
|
||||
unlink = True
|
||||
context_instance = kwargs.pop('context_instance', None) or RequestContext(request)
|
||||
return render_to_string('authentic2_auth_fc/linking.html',
|
||||
{'popup': True, 'unlink' : unlink,
|
||||
'about_url': app_settings.about_url},
|
||||
context_instance=context_instance)
|
||||
unlink = request.user.has_usable_password() or a2_app_settings.A2_REGISTRATION_CAN_CHANGE_PASSWORD
|
||||
|
||||
context = kwargs.pop('context', {}).copy()
|
||||
context.update({
|
||||
'popup': True,
|
||||
'unlink': unlink,
|
||||
'about_url': app_settings.about_url
|
||||
})
|
||||
return render_to_string('authentic2_auth_fc/linking.html', context, request=request)
|
||||
|
||||
def registration(self, request, *args, **kwargs):
|
||||
if 'fc_user_info' in request.session:
|
||||
return []
|
||||
context_instance = kwargs.get('context_instance', RequestContext(request))
|
||||
tpl_parameters = {'about_url': app_settings.about_url}
|
||||
tpl_parameters['registration'] = True
|
||||
return render(request, 'authentic2_auth_fc/login.html',
|
||||
tpl_parameters, context_instance=context_instance)
|
||||
|
||||
context = kwargs.get('context', {}).copy()
|
||||
context.update({
|
||||
'about_url': app_settings.about_url,
|
||||
'registration': True,
|
||||
})
|
||||
return render(request, 'authentic2_auth_fc/login.html', context)
|
||||
|
|
Reference in New Issue