Updated Library view to show an icon if a record exists showing that the library...
[htsworkflow.git] / htsworkflow / frontend / samples / models.py
index 19190ee3e6444605973eea86008b1d901f7198bd..f51d250a8e862f7d562080adf0e0857f7f857e44 100644 (file)
@@ -120,8 +120,8 @@ class Library(models.Model):
   library_species = models.ForeignKey(Species)
   # new field 2008 Mar 5, alter table samples_library add column "hidden" NOT NULL default 0;
   hidden = models.BooleanField()
-  cell_line = models.ForeignKey(Cellline)
-  condition = models.ForeignKey(Condition)
+  cell_line = models.ForeignKey(Cellline, null=True)
+  condition = models.ForeignKey(Condition, null=True)
   antibody = models.ForeignKey(Antibody,blank=True,null=True)
   # New field Aug/25/08. SQL: alter table fctracker_library add column "lib_affiliation" varchar(256)  NULL;
   affiliations = models.ManyToManyField(Affiliation,related_name='library_affiliations',null=True)
@@ -149,7 +149,7 @@ class Library(models.Model):
       ('Done', 'Completed'),
     )
   stopping_point = models.CharField(max_length=25, choices=PROTOCOL_END_POINTS, default='Done')
-  amplified_from_sample = models.ForeignKey('self', blank=True, null=True)  
+  amplified_from_sample = models.ForeignKey('self', blank=True, null=True, related_name='amplified_into_sample')  
   
   undiluted_concentration = models.DecimalField("Concentration", 
       max_digits=5, decimal_places=2, blank=True, null=True,
@@ -183,6 +183,15 @@ class Library(models.Model):
     for t in affs:
         ar.append(t.__unicode__())
     return '%s' % (", ".join(ar))
+    
+  def is_archived(self):
+    """
+    returns True if archived else False
+    """
+    if self.longtermstorage_set.count() > 0:
+        return True
+    else:
+        return False
 
   def libtags(self):
     affs = self.tags.all().order_by('tag_name')
@@ -237,4 +246,4 @@ class Library(models.Model):
 
   @models.permalink
   def get_absolute_url(self):
-    return ('htsworkflow.frontend.samples.views.library_to_flowcells', [str(self.id)])
+    return ('htsworkflow.frontend.samples.views.library_to_flowcells', [str(self.library_id)])