Skip to content

Commit

Permalink
Skip Auditlog catalog if disabled for DX types catalog multiplexer (s…
Browse files Browse the repository at this point in the history
…enaite#2094)

* Check if Auditlog disabled in catalogmultiplexer

* Be graceful when setup container is not yet there

* Changelog updated
  • Loading branch information
ramonski committed Aug 3, 2022
1 parent 3b5a320 commit 42d188c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
2.3.0 (unreleased)
------------------

- #2094 Skip Auditlog catalog if disabled for DX types catalog multiplexer
- #2090 Add support for dates before 1900
- #2089 Fix LDL/UDL cut-off and exponential float conversion
- #2078 Replace dynamic code execution with dynamic import in reports
Expand Down
14 changes: 14 additions & 0 deletions src/senaite/core/catalog/catalog_multiplex_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,26 @@ class CatalogMultiplexProcessor(object):
"""A catalog multiplex processor
"""

def is_global_auditlog_enabled(self):
"""Check if the global auditlogging is enabled
"""
setup = api.get_senaite_setup()
# might happen during installation
if not setup:
return False
return setup.getEnableGlobalAuditlog()

def get_catalogs_for(self, obj):
catalogs = getattr(obj, "_catalogs", [])
for rc in REQUIRED_CATALOGS:
if rc in catalogs:
continue
catalogs.append(rc)

# remove auditlog catalog if disabled
if not self.is_global_auditlog_enabled():
catalogs = filter(lambda cid: cid != AUDITLOG_CATALOG, catalogs)

return map(api.get_tool, catalogs)

def supports_multi_catalogs(self, obj):
Expand Down

0 comments on commit 42d188c

Please sign in to comment.