diff --git a/CHANGES.rst b/CHANGES.rst index a9a955dc98..b5f4c930c7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changelog 2.5.0 (unreleased) ------------------ +- #2350 Display batch labels in listing - #2347 Remove unused inline validation view - #2346 Fix unauthorized error when accessing dispatch/partition sample view with shared client role - #2343 Allow to define the sorting criteria for Result Options diff --git a/src/bika/lims/browser/batchfolder.py b/src/bika/lims/browser/batchfolder.py index 5aec979412..8156b18920 100644 --- a/src/bika/lims/browser/batchfolder.py +++ b/src/bika/lims/browser/batchfolder.py @@ -66,6 +66,9 @@ def __init__(self, context, request): ("BatchID", { "title": _("Batch ID"), "index": "getId", }), + ("BatchLabels", { + "title": _("Batch Labels"), + "sortable": False, }), ("Description", { "title": _("Description"), "sortable": False, }), @@ -156,6 +159,15 @@ def can_add(self): return False return True + def to_pretty_label(self, label): + """Make a pretty label for the given label string + + :param label: text batch label + :returns: Bootstrap HTML batch label + """ + tpl = u"{}" + return tpl.format(api.safe_unicode(label)) + def folderitem(self, obj, item, index): """Applies new properties to the item (Batch) that is currently being rendered as a row in the list @@ -178,6 +190,7 @@ def folderitem(self, obj, item, index): client = obj.getClient() created = api.get_creation_date(obj) date = obj.getBatchDate() + batch_labels = obj.getLabelNames() # total sample progress progress = obj.getProgress() @@ -191,6 +204,12 @@ def folderitem(self, obj, item, index): item["replace"]["Title"] = get_link(url, title) item["created"] = self.ulocalized_time(created, long_format=True) item["BatchDate"] = self.ulocalized_time(date, long_format=True) + item["BatchLabels"] = "" + + if batch_labels: + item["BatchLabels"] = ",".join(batch_labels) + item["replace"]["BatchLabels"] = "".join(map( + self.to_pretty_label, batch_labels)) if client: client_url = api.get_url(client)