Django 1.1 doesn't support validators so remove it for the time
[htsworkflow.git] / htsworkflow / frontend / experiments / models.py
index d28766e153ab94ecc624a670816e1a7177703015..36f6abdb2c9b3d299444941a645080dec182bbe5 100755 (executable)
@@ -13,7 +13,7 @@ from django.db import models
 from django.db.models.signals import post_init
 
 from htsworkflow.frontend.samples.models import Library
-from htsworkflow.frontend.samples.results import parse_flowcell_id
+from htsworkflow.util.conversion import parse_flowcell_id
 from htsworkflow.pipelines import runfolder
 
 logger = logging.getLogger(__name__)
@@ -102,8 +102,9 @@ class FlowCell(models.Model):
 
   @models.permalink
   def get_absolute_url(self):
+      flowcell_id, status = parse_flowcell_id(self.flowcell_id)
       return ('htsworkflow.frontend.experiments.views.flowcell_detail',
-              [str(self.flowcell_id)])
+              [str(flowcell_id)])
     
   def get_raw_data_directory(self):
       """Return location of where the raw data is stored"""
@@ -171,9 +172,15 @@ LANE_STATUS_CODES = [(0, 'Failed'),
 LANE_STATUS_MAP = dict((int(k),v) for k,v in LANE_STATUS_CODES )
 LANE_STATUS_MAP[None] = "Unknown"
 
+def is_valid_lane(value):
+    if value >= 1 and value <= 8:
+        return True
+    else:
+          return False
+
 class Lane(models.Model):
   flowcell = models.ForeignKey(FlowCell)
-  lane_number = models.IntegerField(choices=[(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8)])
+  lane_number = models.IntegerField(
   library = models.ForeignKey(Library)
   pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
   cluster_estimate = models.IntegerField(blank=True, null=True)                                       
@@ -183,9 +190,11 @@ class Lane(models.Model):
   @models.permalink
   def get_absolute_url(self):
        return ('htsworkflow.frontend.experiments.views.flowcell_lane_detail',
-               [str(self.flowcell.flowcell_id), str(self.lane_number)])
+               [str(self.id)])
+
+  def __unicode__(self):
+      return self.flowcell.flowcell_id + ':' + unicode(self.lane_number)
 
-                        
 ### -----------------------
 class DataRun(models.Model):
     flowcell = models.ForeignKey(FlowCell,verbose_name="Flowcell Id")