Move to render and use simple context dictionaries
authorDiane Trout <diane@ghic.org>
Wed, 14 Sep 2016 21:40:33 +0000 (14:40 -0700)
committerDiane Trout <diane@ghic.org>
Wed, 14 Sep 2016 21:40:33 +0000 (14:40 -0700)
render_to_response is likely to be deprecated at some point

experiments/views.py
samples/views.py

index d37836d7de8af143ebee7bc911e05f72167f5445..a2a0e4466ebf41d986ca75e13fd40bce76915e8f 100644 (file)
@@ -142,9 +142,7 @@ def flowcell_detail(request, flowcell_id, lane_number=None):
     else:
         lanes = fc.lane_set.all()
 
-    context = RequestContext(request,
-                             {'flowcell': fc,
-                              'lanes': lanes})
+    context =  {'flowcell': fc, 'lanes': lanes}
 
     return render(request, 'experiments/flowcell_detail.html', context)
 
@@ -160,11 +158,10 @@ def flowcell_lane_detail(request, lane_pk):
                          lane.lane_number,
                          files))
 
-    context = RequestContext(request,
-                             {'lib': lane.library,
-                              'lane': lane,
-                              'flowcell': lane.flowcell,
-                              'filtered_sequencingruns': sequencingruns})
+    context = {'lib': lane.library,
+               'lane': lane,
+               'flowcell': lane.flowcell,
+               'filtered_sequencingruns': sequencingruns}
 
     return render(request, 'experiments/flowcell_lane_detail.html', context)
 
@@ -186,8 +183,7 @@ def read_result_file(self, key):
 
 def sequencer(request, sequencer_id):
     sequencer = get_object_or_404(Sequencer, id=sequencer_id)
-    context = RequestContext(request,
-                             {'sequencer': sequencer})
+    context =  {'sequencer': sequencer}
     return render(request, 'experiments/sequencer.html', context)
 
 
index 3f6ca60764fa072140bf24ea9d0682bac4e12060..f9ed2223976aa4d00fc77b403c45faebb9d6969a 100644 (file)
@@ -8,7 +8,7 @@ import json
 from django.contrib.admin.sites import site as admin_site
 from django.views.decorators.csrf import csrf_exempt
 from django.http import HttpResponse, HttpResponseRedirect, Http404
-from django.shortcuts import render_to_response, get_object_or_404
+from django.shortcuts import render, get_object_or_404
 from django.template import RequestContext
 from django.template.loader import get_template
 from django.contrib.auth.decorators import login_required
@@ -96,10 +96,7 @@ def library_to_flowcells(request, lib_id):
     }
     context.update(SAMPLES_CONTEXT_DEFAULTS)
 
-    return render_to_response(
-        'samples/library_detail.html',
-        context,
-        context_instance=RequestContext(request))
+    return render(request, 'samples/library_detail.html', context)
 
 
 def summaryhtm_fc_cnm(request, flowcell_id, cnm):
@@ -462,16 +459,14 @@ def species_json(request, species_id):
 def species(request, species_id):
     species = get_object_or_404(Species, id=species_id)
 
-    context = RequestContext(request,
-                             {'species': species})
+    context = {'species': species}
 
-    return render_to_response("samples/species_detail.html", context)
+    return render(request, "samples/species_detail.html", context)
 
 
 def antibodies(request):
-    context = RequestContext(request,
-                             {'antibodies': Antibody.objects.order_by('antigene')})
-    return render_to_response("samples/antibody_index.html", context)
+    context = {'antibodies': Antibody.objects.order_by('antigene')}
+    return render(request, "samples/antibody_index.html", context)
 
 
 @login_required
@@ -486,5 +481,4 @@ def user_profile(request):
         # 'select': 'settings',
     }
     context.update(SAMPLES_CONTEXT_DEFAULTS)
-    return render_to_response('registration/profile.html', context,
-                              context_instance=RequestContext(request))
+    return render(requst, 'registration/profile.html', context)