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 @@
# #
###############################################################################
from django.shortcuts import render_to_response, redirect
from django.shortcuts import render, redirect
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.views.generic import TemplateView
from django.contrib.auth.models import User
......@@ -73,15 +73,15 @@ def by_number(request, number):
# return 404
raise Http404('No %s matches the given query.' % Report._meta.object_name)
return render_to_response('reports/report.html',
{
'report_number' : number,
'owner': False,
'report': obj,
'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR,
'show_actionbar': show_actionbar(request, obj)
},
context_instance=RequestContext(request))
return render(request,
'reports/report.html',
{
'report_number' : number,
'owner': False,
'report': obj,
'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR,
'show_actionbar': show_actionbar(request, obj)
})
#------------------------------------------------
......@@ -106,16 +106,16 @@ def for_author(request, author_name, report_name):
# only valid when the author is accessing it and its editable
if isEditable and isAuthor:
return render_to_response('reports/report.html',
{
'author' : author_name,
'report_name' : report_name,
'owner' : (request.user == obj.author),
'report' : obj,
'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR,
'show_actionbar': show_actionbar(request, obj)
},
context_instance=RequestContext(request))
return render(request,
'reports/report.html',
{
'author' : author_name,
'report_name' : report_name,
'owner' : (request.user == obj.author),
'report' : obj,
'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR,
'show_actionbar': show_actionbar(request, obj)
})
# return 404
raise Http404('No %s matches the given query.' % Report._meta.object_name)
......@@ -142,14 +142,13 @@ def ls(request, author_name):
objects = objects.annotate(updated=Coalesce('publication_date', 'creation_date',)).order_by('-updated')
return render_to_response('reports/list.html',
dict(
objects=objects,
author=author,
owner=owner,
),
context_instance=RequestContext(request),
)
return render(request,
'reports/list.html',
dict(
objects=objects,
author=author,
owner=owner,
))
#------------------------------------------------
......@@ -162,14 +161,13 @@ def public_ls(request):
objects = objects.annotate(updated=Coalesce('publication_date', 'creation_date',)).order_by('-updated')
return render_to_response('reports/list.html',
dict(
objects=objects,
author=request.user,
owner=False,
),
context_instance=RequestContext(request),
)
return render(request,
'reports/list.html',
dict(
objects=objects,
author=request.user,
owner=False,
))
#------------------------------------------------
......
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