Prototype of bcmagic search plugin.
[htsworkflow.git] / htsworkflow / frontend / inventory / models.py
index e98bd5ef77b3d718a57ab0bcd3e9086044f127b3..444d3c5f6c6009f5793e5b2131d6dd1eb0d63cd8 100644 (file)
@@ -123,6 +123,9 @@ class Item(models.Model):
         else:
             return u"invb|%s" % (self.barcode_id)
             
+    def get_absolute_url(self):
+        return '/inventory/%s/' % (self.uuid)
+            
 pre_save.connect(_assign_uuid, sender=Item)
 
 
@@ -138,4 +141,35 @@ class LongTermStorage(models.Model):
     
     def __unicode__(self):
         return u"%s: %s" % (str(self.flowcell), ', '.join([ str(s) for s in self.storage_devices.iterator() ]))
+        
+
+
+class ReagentBase(models.Model):
+    
+    reagent = models.ManyToManyField(Item)
+    
+    creation_date = models.DateTimeField(auto_now_add=True)
+    modified_date = models.DateTimeField(auto_now=True)
+    
+    class Meta:
+        abstract = True
 
+
+class ReagentFlowcell(ReagentBase):
+    """
+    Links reagents and flowcells
+    """
+    flowcell = models.ForeignKey(FlowCell)
+    
+    def __unicode__(self):
+        return u"%s: %s" % (str(self.flowcell), ', '.join([ str(s) for s in self.reagent.iterator() ]))
+   
+
+class ReagentLibrary(ReagentBase):
+    """
+    Links libraries and flowcells
+    """
+    library = models.ForeignKey(Library)
+    
+    def __unicode__(self):
+        return u"%s: %s" % (str(self.library), ', '.join([ str(s) for s in self.reagent.iterator() ]))