From 601609048fd8b93ff490f65f87595cd5bf029780 Mon Sep 17 00:00:00 2001 From: Dwayne Bailey Date: Fri, 28 Oct 2016 14:00:33 +0100 Subject: [PATCH] Use explicit arguments in template.render() Django 1.8 deprecates some arguments, adds more. Django 1.10 removes some and thus positional arguments will change. Prevent bugs now. --- pootle/apps/pootle_store/views.py | 10 ++++++---- pootle/apps/staticpages/views.py | 2 +- tests/core/formtable.py | 2 +- tests/views/timeline.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pootle/apps/pootle_store/views.py b/pootle/apps/pootle_store/views.py index 2de39983acd..5979ee32abf 100644 --- a/pootle/apps/pootle_store/views.py +++ b/pootle/apps/pootle_store/views.py @@ -147,7 +147,7 @@ def _get_critical_checks_snippet(request, unit): 'unit': unit, } template = loader.get_template('editor/units/xhr_checks.html') - return template.render(ctx, request) + return template.render(context=ctx, request=request) @ajax_required @@ -259,7 +259,8 @@ def save_comment(request, unit): } t = loader.get_template('editor/units/xhr_comment.html') - return JsonResponse({'comment': t.render(ctx, request)}) + return JsonResponse({'comment': t.render(context=ctx, + request=request)}) return JsonResponseBadRequest({'msg': _("Comment submission failed.")}) @@ -340,7 +341,7 @@ def get_response_data(self, context): 'timeline': self.render_timeline(context)} def render_timeline(self, context): - return loader.get_template(self.template_name).render(context) + return loader.get_template(self.template_name).render(context=context) def get_entries_group_data(self, context): result = [] @@ -367,7 +368,8 @@ def get_edit_template(self): return loader.get_template('editor/units/edit.html') def render_edit_template(self, context): - return self.get_edit_template().render(context, self.request) + return self.get_edit_template().render(context=context, + request=self.request) def get_source_nplurals(self): if self.object.hasplural(): diff --git a/pootle/apps/staticpages/views.py b/pootle/apps/staticpages/views.py index ae8ca472ba0..5bc2f3de5db 100644 --- a/pootle/apps/staticpages/views.py +++ b/pootle/apps/staticpages/views.py @@ -199,7 +199,7 @@ def display_page(request, virtual_path): def _get_rendered_agreement(request, form): template = get_template('staticpages/agreement.html') - return template.render({'form': form}, request) + return template.render(context={'form': form}, request=request) @ajax_required diff --git a/tests/core/formtable.py b/tests/core/formtable.py index 06a1588859e..bc798815075 100644 --- a/tests/core/formtable.py +++ b/tests/core/formtable.py @@ -47,7 +47,7 @@ def test_formtable(): def _render_template(string, context=None): context = context or {} context = Context(context) - return Template(string).render(context) + return Template(string).render(context=context) @pytest.mark.django diff --git a/tests/views/timeline.py b/tests/views/timeline.py index c70cb838f3d..5c6cb66b047 100644 --- a/tests/views/timeline.py +++ b/tests/views/timeline.py @@ -208,7 +208,7 @@ def _calculate_timeline(request, unit): entries_group.reverse() context['entries_group'] = entries_group t = loader.get_template('editor/units/xhr_timeline.html') - return t.render(context, request) + return t.render(context=context, request=request) def _timeline_test(client, request_user, unit):