From 15bcbdc1b321562ca30a6faf84602a615f468d7a Mon Sep 17 00:00:00 2001 From: Anneline Date: Wed, 23 Nov 2022 14:23:07 +0200 Subject: [PATCH 1/4] Apply category sort order on analysis specifications --- .../widgets/analysisspecificationwidget.py | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/bika/lims/browser/widgets/analysisspecificationwidget.py b/src/bika/lims/browser/widgets/analysisspecificationwidget.py index 9b2e48e86d..1274676a8c 100644 --- a/src/bika/lims/browser/widgets/analysisspecificationwidget.py +++ b/src/bika/lims/browser/widgets/analysisspecificationwidget.py @@ -35,6 +35,8 @@ from plone.memoize import view from Products.Archetypes.Registry import registerWidget from Products.Archetypes.Widget import TypesWidget +from Products.CMFCore.utils import getToolByName + class AnalysisSpecificationView(BikaListingView): @@ -43,7 +45,6 @@ class AnalysisSpecificationView(BikaListingView): def __init__(self, context, request): super(AnalysisSpecificationView, self).__init__(context, request) - self.catalog = "senaite_catalog_setup" self.contentFilter = { "portal_type": "AnalysisService", @@ -170,8 +171,25 @@ def get_dynamic_analysisspecs(self): return self.dynamic_spec.get_by_keyword() def folderitems(self): + """Sort by Categories + """ + + bsc = getToolByName(self.context, "senaite_catalog_setup") + self.an_cats = bsc( + portal_type="AnalysisCategory", + sort_on="sortable_title") + self.an_cats_order = dict([ + (b.Title, "{:04}".format(a)) + for a, b in enumerate(self.an_cats)]) + items = super(AnalysisSpecificationView, self).folderitems() - self.categories.sort() + + + if self.show_categories_enabled(): + self.categories = map(lambda x: x[0], + sorted(self.categories, key=lambda x: x[1])) + else: + self.categories.sort() return items def folderitem(self, obj, item, index): @@ -189,6 +207,8 @@ def folderitem(self, obj, item, index): url = api.get_url(obj) title = api.get_title(obj) keyword = obj.getKeyword() + cat = obj.getCategoryTitle() + cat_order = self.an_cats_order.get(cat) # dynamic analysisspecs dspecs = self.get_dynamic_analysisspecs() @@ -203,8 +223,8 @@ def folderitem(self, obj, item, index): # get the category if self.show_categories_enabled(): category = obj.getCategoryTitle() - if category not in self.categories: - self.categories.append(category) + if (category,cat_order) not in self.categories: + self.categories.append((category,cat_order)) item["category"] = category item["Title"] = title From 425244d0770f82f5ac09af901e6dbaa71685b6a5 Mon Sep 17 00:00:00 2001 From: Anneline Date: Wed, 23 Nov 2022 14:36:29 +0200 Subject: [PATCH 2/4] CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 1f132d4350..af97b8b629 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changelog 2.4.0 (unreleased) ------------------ +- #2191 Apply category sort order on analysis specifications - #2190 Fix sample actions without translation - #2189 Fix auto-print of barcode labels when auto-receive is enabled - #2188 Fix archive path for Generic Setup file imports From 1541f72478c90d83e72eb5b02a73e0bbcf70892f Mon Sep 17 00:00:00 2001 From: Anneline Date: Wed, 15 Mar 2023 12:53:11 +0200 Subject: [PATCH 3/4] Removed space flagged by LINT --- src/bika/lims/browser/widgets/analysisspecificationwidget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bika/lims/browser/widgets/analysisspecificationwidget.py b/src/bika/lims/browser/widgets/analysisspecificationwidget.py index 1274676a8c..30ddf1d65c 100644 --- a/src/bika/lims/browser/widgets/analysisspecificationwidget.py +++ b/src/bika/lims/browser/widgets/analysisspecificationwidget.py @@ -223,7 +223,7 @@ def folderitem(self, obj, item, index): # get the category if self.show_categories_enabled(): category = obj.getCategoryTitle() - if (category,cat_order) not in self.categories: + if (category,cat_order) not in self.categories: self.categories.append((category,cat_order)) item["category"] = category From d88d2fe16023f257405ef3a8e3407e967249f12a Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Thu, 4 Jan 2024 21:04:40 +0100 Subject: [PATCH 4/4] Update CHANGES.rst typo --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index db0ba098fc..b17d6549fb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -124,7 +124,7 @@ Changelog - #2279 Allow all custom transitions in sample report listing - #2278 Client catalog - #2276 Senaite labels -- #2275 Fix wrong result when both "Result options" and "String" are ena +- #2275 Fix wrong result when both "Result options" and "String" are enabled - #2273 Improve performance for sample listing index - #2272 Allow to configure the position of additional value columns