Skip to content
Snippets Groups Projects
Commit 41d30121 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[reports][views] Moved from render_to_response to render

render_to_response is deprecated in Django 2.0 and render has
been available since 1.3. It's shorter to write and avoids the
writing of context_instance=RequestContext(request) in each of
its call.
parent e03ff815
No related branches found
No related tags found
2 merge requests!2551.4.x,!238Upgrade to django 1.11
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
# # # #
############################################################################### ###############################################################################
from django.shortcuts import render_to_response, redirect from django.shortcuts import render, redirect
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.template import RequestContext, Context from django.template import Context
from django.conf import settings from django.conf import settings
from django.views.generic import TemplateView from django.views.generic import TemplateView
from django.contrib.auth.models import User from django.contrib.auth.models import User
...@@ -73,15 +73,15 @@ def by_number(request, number): ...@@ -73,15 +73,15 @@ def by_number(request, number):
# return 404 # return 404
raise Http404('No %s matches the given query.' % Report._meta.object_name) raise Http404('No %s matches the given query.' % Report._meta.object_name)
return render_to_response('reports/report.html', return render(request,
{ 'reports/report.html',
'report_number' : number, {
'owner': False, 'report_number' : number,
'report': obj, 'owner': False,
'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR, 'report': obj,
'show_actionbar': show_actionbar(request, obj) 'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR,
}, 'show_actionbar': show_actionbar(request, obj)
context_instance=RequestContext(request)) })
#------------------------------------------------ #------------------------------------------------
...@@ -106,16 +106,16 @@ def for_author(request, author_name, report_name): ...@@ -106,16 +106,16 @@ def for_author(request, author_name, report_name):
# only valid when the author is accessing it and its editable # only valid when the author is accessing it and its editable
if isEditable and isAuthor: if isEditable and isAuthor:
return render_to_response('reports/report.html', return render(request,
{ 'reports/report.html',
'author' : author_name, {
'report_name' : report_name, 'author' : author_name,
'owner' : (request.user == obj.author), 'report_name' : report_name,
'report' : obj, 'owner' : (request.user == obj.author),
'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR, 'report' : obj,
'show_actionbar': show_actionbar(request, obj) 'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR,
}, 'show_actionbar': show_actionbar(request, obj)
context_instance=RequestContext(request)) })
# return 404 # return 404
raise Http404('No %s matches the given query.' % Report._meta.object_name) raise Http404('No %s matches the given query.' % Report._meta.object_name)
...@@ -142,14 +142,13 @@ def ls(request, author_name): ...@@ -142,14 +142,13 @@ def ls(request, author_name):
objects = objects.annotate(updated=Coalesce('publication_date', 'creation_date',)).order_by('-updated') objects = objects.annotate(updated=Coalesce('publication_date', 'creation_date',)).order_by('-updated')
return render_to_response('reports/list.html', return render(request,
dict( 'reports/list.html',
objects=objects, dict(
author=author, objects=objects,
owner=owner, author=author,
), owner=owner,
context_instance=RequestContext(request), ))
)
#------------------------------------------------ #------------------------------------------------
...@@ -162,14 +161,13 @@ def public_ls(request): ...@@ -162,14 +161,13 @@ def public_ls(request):
objects = objects.annotate(updated=Coalesce('publication_date', 'creation_date',)).order_by('-updated') objects = objects.annotate(updated=Coalesce('publication_date', 'creation_date',)).order_by('-updated')
return render_to_response('reports/list.html', return render(request,
dict( 'reports/list.html',
objects=objects, dict(
author=request.user, objects=objects,
owner=False, author=request.user,
), owner=False,
context_instance=RequestContext(request), ))
)
#------------------------------------------------ #------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment