django-nose didn't work with django 1.1, so I went back to the nose plugin NoseDjango
[htsworkflow.git] / htsworkflow / frontend / experiments / experiments.py
index 3e17e04d873b39721c2d6296b772666cc9df2b87..5dec8cf5871bc640050c68b1118da2a3c073b400 100755 (executable)
@@ -12,10 +12,14 @@ from django.contrib.auth.decorators import login_required
 from django.core.exceptions import ObjectDoesNotExist
 from django.core.mail import send_mail, mail_admins
 from django.http import HttpResponse, Http404
+from django.conf import settings
 
 from htsworkflow.frontend.auth import require_api_key
-from htsworkflow.frontend import settings
-from htsworkflow.frontend.experiments.models import FlowCell, DataRun, Lane
+from htsworkflow.frontend.experiments.models import \
+    FlowCell, \
+    DataRun, \
+    Lane, \
+    LANE_STATUS_MAP
 from htsworkflow.frontend.samples.models import Library, HTSUser
 
 def flowcell_information(flowcell_id):
@@ -23,7 +27,7 @@ def flowcell_information(flowcell_id):
     Return a dictionary describing a flowcell
     """
     try:
-        fc = FlowCell.objects.get(flowcell_id=flowcell_id)
+        fc = FlowCell.objects.get(flowcell_id__startswith=flowcell_id)
     except FlowCell.DoesNotExist, e:
         return None
 
@@ -40,7 +44,9 @@ def flowcell_information(flowcell_id):
             'library_id': lane.library.id,
             'library_species': lane.library.library_species.scientific_name,
             'pM': unicode(lane.pM),
-            'read_length': lane.flowcell.read_length
+            'read_length': lane.flowcell.read_length,
+            'status_code': lane.status,
+            'status': LANE_STATUS_MAP[lane.status]
         }
 
     if fc.control_lane is None:
@@ -91,14 +97,19 @@ def lanes_for(username=None):
         query.update({'library__affiliations__users__id': user.id})
         
     lanes = Lane.objects.filter(**query).order_by('-flowcell__run_date')
+
     
     result = []
     for l in lanes:
+        affiliations = l.library.affiliations.all()
+        affiliations_list = [(a.id, a.name) for a in affiliations]
         result.append({ 'flowcell': l.flowcell.flowcell_id,
                         'run_date': l.flowcell.run_date.isoformat(),
                         'lane_number': l.lane_number,
                         'library': l.library.id,
-                        'comment': l.comment})
+                        'library_name': l.library.library_name,
+                        'comment': l.comment,
+                        'affiliations': affiliations_list})
     return result
 
 def lanes_for_json(request, username):