Skip to content

Commit

Permalink
Moved to bika.extras
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunga001 committed Sep 11, 2023
1 parent 1fedddd commit bfc83ab
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions src/bika/lims/browser/widgets/artemplateanalyseswidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from Products.Archetypes.Registry import registerWidget
from Products.Archetypes.Widget import TypesWidget
from zope.i18n.locales import locales
from Products.CMFCore.utils import getToolByName


class ARTemplateAnalysesView(BikaListingView):
Expand All @@ -44,8 +43,6 @@ class ARTemplateAnalysesView(BikaListingView):
def __init__(self, context, request):
super(ARTemplateAnalysesView, self).__init__(context, request)

self.an_cats = None
self.an_cats_order = None
self.catalog = "senaite_catalog_setup"
self.contentFilter = {
"portal_type": "AnalysisService",
Expand Down Expand Up @@ -200,24 +197,10 @@ def get_editable_columns(self):
return columns

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(ARTemplateAnalysesView, self).folderitems()
if self.show_categories_enabled():
self.categories = map(lambda x: x[0],
sorted(self.categories, key=lambda x: x[1]))
else:
self.categories.sort()
self.categories.sort()
return items


def folderitem(self, obj, item, index):
"""Service triggered each time an item is iterated in folderitems.
Expand All @@ -233,14 +216,12 @@ def folderitem(self, obj, item, index):
uid = api.get_uid(obj)
url = api.get_url(obj)
title = api.get_title(obj)
cat = obj.getCategoryTitle()
cat_order = self.an_cats_order.get(cat)

# get the category
category = obj.getCategoryTitle()
item["category"] = category
if (category,cat_order) not in self.categories:
self.categories.append((category,cat_order))
if category not in self.categories:
self.categories.append(category)

config = self.configuration.get(uid, {})
partition = config.get("partition", "part-1")
Expand Down

0 comments on commit bfc83ab

Please sign in to comment.