Define the unicode() function for HTSUser to also report the users full name.
[htsworkflow.git] / htsworkflow / frontend / samples / views.py
index f42c8bce7d53984ed227c696d487898a533ff755..a14b22ccb6a92c7983d52ea0cfc0967ab26b901e 100644 (file)
@@ -7,6 +7,7 @@ try:
 except ImportError, e:
     import simplejson as json
 
+from htsworkflow.frontend.auth import require_api_key
 from htsworkflow.frontend.experiments.models import FlowCell
 from htsworkflow.frontend.samples.changelist import ChangeList
 from htsworkflow.frontend.samples.models import Library
@@ -40,11 +41,11 @@ def create_library_context(cl):
     #for lib in library_items.object_list:
     for lib in cl.result_list:
        summary = {}
-       summary['library_id'] = lib.library_id
+       summary['library_id'] = lib.id
        summary['library_name'] = lib.library_name
        summary['species_name' ] = lib.library_species.scientific_name
        if lib.amplified_from_sample is not None:
-           summary['amplified_from'] = lib.amplified_from_sample.library_id
+           summary['amplified_from'] = lib.amplified_from_sample.id
        else:
            summary['amplified_from'] = ''
        lanes_run = 0
@@ -62,7 +63,7 @@ def library(request):
    # build changelist
     fcl = ChangeList(request, Library,
         list_filter=['affiliations', 'library_species'],
-        search_fields=['library_id', 'library_name', 'amplified_from_sample__library_id'],
+        search_fields=['id', 'library_name', 'amplified_from_sample__id'],
         list_per_page=200,
         queryset=Library.objects.filter(hidden__exact=0)
     )
@@ -89,7 +90,7 @@ def library_to_flowcells(request, lib_id):
     """
     
     try:
-      lib = Library.objects.get(library_id=lib_id)
+      lib = Library.objects.get(id=lib_id)
     except:
       return HttpResponse("Library %s does not exist" % (lib_id))
    
@@ -381,6 +382,7 @@ def _make_eland_results(flowcell_id, lane, interesting_flowcells):
         result_path = cur_fc[cycle]['eland_results'].get(lane, None)
         result_link = make_result_link(fc_id, cycle, lane, result_path)
         results.append({'flowcell_id': fc_id,
+                        'run_date': flowcell.run_date,
                         'cycle': cycle, 
                         'lane': lane, 
                         'summary_url': make_summary_url(flowcell_id, cycle),
@@ -445,7 +447,7 @@ def _files(flowcell_id, lane):
     return '(' + '|'.join(output) + ')'
 
 def library_id_to_admin_url(request, lib_id):
-    lib = Library.objects.get(library_id=lib_id)
+    lib = Library.objects.get(id=lib_id)
     return HttpResponseRedirect('/admin/samples/library/%s' % (lib.id,))
 
 def library_dict(library_id):
@@ -454,7 +456,7 @@ def library_dict(library_id):
     return None if nothing was found
     """
     try:
-        lib = Library.objects.get(library_id = library_id)
+        lib = Library.objects.get(id = library_id)
     except Library.DoesNotExist, e:
         return None
 
@@ -471,7 +473,7 @@ def library_dict(library_id):
         'experiment_type': lib.experiment_type.name,
         'experiment_type_id': lib.experiment_type_id,
         'id': lib.id,
-        'library_id': lib.library_id,
+        'library_id': lib.id,
         'library_name': lib.library_name,
         'library_species': lib.library_species.scientific_name,
         'library_species_id': lib.library_species_id,
@@ -491,11 +493,11 @@ def library_dict(library_id):
         info['library_type'] = lib.library_type.name
     return info
 
-@login_required
 def library_json(request, library_id):
     """
     Return a json formatted library dictionary
     """
+    require_api_key(request)
     # what validation should we do on library_id?
     
     lib = library_dict(library_id)