From fb434252e609ab2576a428f6e3bc388ced622aec Mon Sep 17 00:00:00 2001
From: Samuel Gaist <samuel.gaist@idiap.ch>
Date: Wed, 7 Mar 2018 15:16:00 +0100
Subject: [PATCH] [attestations][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.
---
 beat/web/attestations/views.py | 47 ++++++++++++++++------------------
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git a/beat/web/attestations/views.py b/beat/web/attestations/views.py
index 64e73a0ed..62d10e536 100644
--- a/beat/web/attestations/views.py
+++ b/beat/web/attestations/views.py
@@ -31,8 +31,7 @@
 
 
 from django.shortcuts import get_object_or_404
-from django.shortcuts import render_to_response
-from django.template import RequestContext
+from django.shortcuts import render
 from django.contrib.auth.models import User
 from django.db.models import Q
 
@@ -46,13 +45,13 @@ def view(request, number):
     (has_access, _) = attestation.experiment.accessibility_for(request.user)
 
     # Render the page
-    return render_to_response('attestations/view.html',
-                              dict(
-                                  attestation=attestation,
-                                  has_access=has_access,
-                                  owner=(attestation.experiment.author == request.user),
-                              ),
-                              context_instance=RequestContext(request))
+    return render(request,
+                  'attestations/view.html',
+                  dict(
+                      attestation=attestation,
+                      has_access=has_access,
+                      owner=(attestation.experiment.author == request.user)
+                  ))
 
 
 def ls(request, author_name):
@@ -75,14 +74,13 @@ def ls(request, author_name):
 
     objects = objects.order_by('-locked', 'expiration_date')
 
-    return render_to_response('attestations/list.html',
-                              dict(
-                                  objects=objects,
-                                  author=author,
-                                  owner=(request.user==author),
-                              ),
-                              context_instance=RequestContext(request),
-    )
+    return render(request,
+                  'attestations/list.html',
+                  dict(
+                      objects=objects,
+                      author=author,
+                      owner=(request.user == author)
+                  ))
 
 
 def public_ls(request):
@@ -91,11 +89,10 @@ def public_ls(request):
     # orders so that recent objects are displayed first
     objects = Attestation.objects.filter(locked=False).order_by('-publication_date')
 
-    return render_to_response('attestations/list.html',
-                              dict(
-                                  objects=objects,
-                                  author=request.user, #anonymous
-                                  owner=False,
-                              ),
-                              context_instance=RequestContext(request),
-    )
+    return render(request,
+                  'attestations/list.html',
+                  dict(
+                      objects=objects,
+                      author=request.user, # anonymous
+                      owner=False,
+                  ))
-- 
GitLab