From cb1c999c28a1f892549036a5c832465a3939417c Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Thu, 8 Oct 2009 00:13:17 +0000 Subject: [PATCH] Use raw_id_fields for the library ID in the Flowcell Lane Inline form 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 | 71 ++++++++++++++--------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/htsworkflow/frontend/experiments/admin.py b/htsworkflow/frontend/experiments/admin.py index 1a4a93f..ca3f730 100644 --- a/htsworkflow/frontend/experiments/admin.py +++ b/htsworkflow/frontend/experiments/admin.py @@ -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) -- 2.30.2