Record new minor release.
[htsworkflow.git] / htsworkflow / frontend / samples / admin.py
index 594cf35d4aa94d19b22a60904b513cc144e7f234..23b99f8d7421cf073d835a9418354472a703e082 100644 (file)
@@ -12,6 +12,9 @@ from htsworkflow.frontend.experiments.models import Lane
 from htsworkflow.frontend.inventory.models import PrinterTemplate
 from htsworkflow.frontend.bcmagic.utils import print_zpl_socket
 
+# Let's disable those pesky delete everything by accident features.
+admin.site.disable_action('delete_selected')
+
 class AffiliationOptions(admin.ModelAdmin):
     list_display = ('name','contact','email')
     fieldsets = (
@@ -145,7 +148,14 @@ class LibraryOptions(admin.ModelAdmin):
           ('cell_line','condition','antibody'),)
          }),
          ('Creation Information:', {
-             'fields' : (('made_for', 'made_by', 'creation_date'), ('stopping_point', 'amplified_from_sample'), ('avg_lib_size','undiluted_concentration', 'ten_nM_dilution', 'successful_pM'), 'account_number', 'notes',)
+             'fields' : (('made_for', 'made_by', 'creation_date'), 
+                         ('stopping_point', 'amplified_from_sample'), 
+                         ('gel_cut_size', 'insert_size', 
+                          'undiluted_concentration', 'ten_nM_dilution', 
+                          'successful_pM'), 
+                         ('bioanalyzer_concentration','bioanalyzer_image_url'),
+                         ('bioanalyzer_summary'), 
+                         ('account_number', 'notes',))
          }),
          ('Library/Project Affiliation:', {
              'fields' : (('affiliations'), ('tags'),)
@@ -156,7 +166,6 @@ class LibraryOptions(admin.ModelAdmin):
     ]
     actions = ['action_print_library_labels']
     
-    
     def action_print_library_labels(self, request, queryset):
         """
         Django action which prints labels for the selected set of labels from the
@@ -180,6 +189,7 @@ class LibraryOptions(admin.ModelAdmin):
         # ZPL Template
         t = Template(template.template)
         
+        zpl_list = []
         #Iterate over selected labels to print
         for library in queryset.all():
             
@@ -188,25 +198,27 @@ class LibraryOptions(admin.ModelAdmin):
             
             # Send rendered template to the printer that the template
             #  object has been attached to in the database.
-            print_zpl_socket(t.render(c), host=template.printer.ip_address)
+            zpl_list.append(t.render(c))
+        
+        print_zpl_socket(zpl_list, host=template.printer.ip_address)
     
         self.message_user(request, "%s labels printed." % (len(queryset)))
                           
     action_print_library_labels.short_description = "Print Labels"
 
-
-
-    # some post 1.0.2 version of django has formfield_overrides 
-    # which would replace this code with:
-    # formfield_overrids = {
-    #    models.ManyToMany: { 'widget': widgets.FilteredSelectMultiple }
-    #}
     def formfield_for_dbfield(self, db_field, **kwargs):
-      if db_field.name in ('affiliations', 'tags'):
-        kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name,
-                                                          (db_field.name in self.filter_vertical))
-      rv = super(LibraryOptions, self).formfield_for_dbfield(db_field, **kwargs)
-      return rv
+        # Override Field type
+        if db_field.name in ('affiliations', 'tags'):
+            kwargs['widget'] = widgets.FilteredSelectMultiple(
+                db_field.verbose_name,
+                (db_field.name in self.filter_vertical)
+            )
+        field = super(LibraryOptions, self).formfield_for_dbfield(db_field,
+                                                                  **kwargs)
+        # Override field attributes
+        if db_field.name == "bioanalyzer_summary":
+            field.widget.attrs["rows"] = "3"
+        return field
 
 class SpeciesOptions(admin.ModelAdmin):
     fieldsets = (