Use raw_id_fields for the library ID in the Flowcell Lane Inline form
authorDiane Trout <diane@caltech.edu>
Thu, 8 Oct 2009 00:13:17 +0000 (00:13 +0000)
committerDiane Trout <diane@caltech.edu>
Thu, 8 Oct 2009 00:13:17 +0000 (00:13 +0000)
this provides a vastly superior choice for searching a large number of
database entries.

I also grouped the various Lane form customization elements together
as I was tired of scrolling up and down in the file.

htsworkflow/frontend/experiments/admin.py

index 1a4a93f75c312e6c0634a414cde37264d3e82368..ca3f7308f5827105643d2aed2f7be0c5a8801a4b 100644 (file)
@@ -1,23 +1,11 @@
 from htsworkflow.frontend.experiments.models import FlowCell, DataRun, ClusterStation, Sequencer, Lane
 from django.contrib import admin
+from django.contrib.admin.widgets import FilteredSelectMultiple
 from django.forms import ModelForm
-from django.forms.fields import CharField
+from django.forms.fields import Field, CharField
 from django.forms.widgets import TextInput
 from django.utils.translation import ugettext_lazy as _
 
-
-class LaneForm(ModelForm):
-    comment = CharField(widget=TextInput(attrs={'size':'80'}), required=False)
-    
-    class Meta:
-        model = Lane
-
-class LaneInline(admin.StackedInline):
-  model = Lane
-  max_num = 8
-  extra = 8
-  form = LaneForm
-
 class DataRunOptions(admin.ModelAdmin):
   search_fields = [
       'run_folder',
@@ -48,6 +36,49 @@ class DataRunOptions(admin.ModelAdmin):
   ]
   list_filter = ('run_status', 'run_start_time')
 
+# lane form setup needs to come before Flowcell form config
+# as flowcell refers to the LaneInline class
+class LaneForm(ModelForm):
+    comment = CharField(widget=TextInput(attrs={'size':'80'}), required=False)
+    
+    class Meta:
+        model = Lane
+
+class LaneInline(admin.StackedInline):
+    """
+    Controls display of Lanes on the Flowcell form.
+    """
+    model = Lane
+    max_num = 8
+    extra = 8
+    form = LaneForm
+    raw_id_fields = ('library',)
+    fieldsets = (
+      (None, {
+        'fields': ('lane_number', 'flowcell',
+                   ('library',),
+                   ('pM', 'cluster_estimate'),
+                   'comment',)
+      }),
+    )
+
+class LaneOptions(admin.ModelAdmin):
+    """
+    Controls display of Lane browser
+    """
+    list_display = ('flowcell', 'lane_number', 'library', 'comment')
+    fieldsets = (
+      (None, {
+        'fields': ('lane_number', 'flowcell',
+                   ('library'),
+                   ('pM', 'cluster_estimate'))
+      }),
+      ('Optional', {
+        'classes': ('collapse', ),
+        'fields': ('comment', )
+      }),
+    )
+    
 class FlowCellOptions(admin.ModelAdmin):
     date_hierarchy = "run_date"
     save_on_top = True
@@ -79,18 +110,6 @@ class SequencerOptions(admin.ModelAdmin):
     list_display = ('name', )
     fieldsets = ( ( None, { 'fields': ( 'name', ) } ), )
     
-class LaneOptions(admin.ModelAdmin):
-    list_display = ('flowcell', 'lane_number', 'library', 'comment')
-    fieldsets = (
-      (None, {
-        'fields': ('lane_number', 'flowcell', 'library', 'pM', 'cluster_estimate')
-      }),
-      ('Optional', {
-        'classes': ('collapse', ),
-        'fields': ('comment', )
-      }),
-    )
-    
 
 admin.site.register(DataRun, DataRunOptions)
 admin.site.register(FlowCell, FlowCellOptions)