File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 1313 ExtractionPlate ,
1414 Order ,
1515 Sample ,
16- SampleIsolationMethod ,
1716 SampleMarkerAnalysis ,
1817)
1918from nina .models import Project
@@ -457,10 +456,11 @@ class OrderAnalysisSampleTable(tables.Table):
457456 },
458457 )
459458
460- isolation_method = tables .Column (
459+ isolation_method = tables .ManyToManyColumn (
460+ accessor = "sample__isolation_method" ,
461+ transform = lambda x : x .name ,
461462 verbose_name = "Isolation Method" ,
462- accessor = "sample" , # needed to get `record.sample` instead of `None`
463- empty_values = (),
463+ orderable = False ,
464464 )
465465
466466 class Meta :
@@ -488,13 +488,6 @@ def render_checked(self, record: SampleMarkerAnalysis) -> str:
488488 record .id ,
489489 )
490490
491- def render_isolation_method (self , record : SampleMarkerAnalysis ) -> str :
492- print (record )
493- qs = SampleIsolationMethod .objects .filter (sample = record .sample ).values_list (
494- "isolation_method__name" , flat = True
495- )
496- return ", " .join (qs )
497-
498491
499492class PlateTable (tables .Table ):
500493 id = tables .Column (
Original file line number Diff line number Diff line change @@ -559,7 +559,14 @@ def get_order(self) -> ExtractionOrder:
559559 def get_queryset (self ) -> QuerySet [Sample ]:
560560 return Sample .objects .filter (
561561 order = self .get_order (), genlab_id__isnull = False
562- ).prefetch_related ("order" , "type" , "isolation_method" )
562+ ).prefetch_related (
563+ "order" ,
564+ "type" ,
565+ Prefetch (
566+ "isolation_method" ,
567+ queryset = IsolationMethod .objects .order_by ("name" ).distinct (),
568+ ),
569+ )
563570
564571 def get_isolation_methods (self ) -> QuerySet [IsolationMethod , str ]:
565572 types = self .get_queryset ().values_list ("type" , flat = True ).distinct ()
You can’t perform that action at this time.
0 commit comments