|
2 | 2 |
|
3 | 3 | from AccessControl import ClassSecurityInfo
|
4 | 4 | from bika.lims import api
|
| 5 | +from plone.app.textfield import IRichTextValue |
| 6 | +from plone.app.textfield.widget import RichTextFieldWidget # TBD: port to core |
5 | 7 | from plone.autoform import directives
|
6 | 8 | from plone.supermodel import model
|
7 |
| -from plone.app.textfield.widget import RichTextFieldWidget # TBD: port to core |
8 |
| -from plone.app.textfield import IRichTextValue |
9 | 9 | from Products.CMFCore import permissions
|
10 | 10 | from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
|
| 11 | +from senaite.core.catalog import AUDITLOG_CATALOG |
11 | 12 | from senaite.core.content.base import Container
|
12 | 13 | from senaite.core.interfaces import IHideActionsMenu
|
13 | 14 | from senaite.core.interfaces import ISetup
|
14 | 15 | from senaite.core.schema import RichTextField
|
15 | 16 | from senaite.impress import senaiteMessageFactory as _
|
| 17 | +from zope import schema |
16 | 18 | from zope.interface import implementer
|
17 | 19 | from zope.interface import provider
|
18 | 20 | from zope.schema.interfaces import IContextAwareDefaultFactory
|
@@ -44,6 +46,17 @@ class ISetupSchema(model.Schema):
|
44 | 46 | required=False,
|
45 | 47 | )
|
46 | 48 |
|
| 49 | + enable_global_auditlog = schema.Bool( |
| 50 | + title=_(u"Enable global Auditlog"), |
| 51 | + description=_( |
| 52 | + "The global Auditlog shows all modifications of the system. " |
| 53 | + "When enabled, all entities will be indexed in a separate " |
| 54 | + "catalog. This will increase the time when objects are " |
| 55 | + "created or modified." |
| 56 | + ), |
| 57 | + default=False, |
| 58 | + ) |
| 59 | + |
47 | 60 | ###
|
48 | 61 | # Fieldsets
|
49 | 62 | ###
|
@@ -83,3 +96,21 @@ def setEmailBodySamplePublication(self, value):
|
83 | 96 | """
|
84 | 97 | mutator = self.mutator("email_body_sample_publication")
|
85 | 98 | return mutator(self, value)
|
| 99 | + |
| 100 | + @security.protected(permissions.View) |
| 101 | + def getEnableGlobalAuditlog(self): |
| 102 | + """Returns if the global Auditlog is enabled |
| 103 | + """ |
| 104 | + accessor = self.accessor("enable_global_auditlog") |
| 105 | + return accessor(self) |
| 106 | + |
| 107 | + @security.protected(permissions.ModifyPortalContent) |
| 108 | + def setEnableGlobalAuditlog(self, value): |
| 109 | + """Enable/Disable global Auditlogging |
| 110 | + """ |
| 111 | + if value is False: |
| 112 | + # clear the auditlog catalog |
| 113 | + catalog = api.get_tool(AUDITLOG_CATALOG) |
| 114 | + catalog.manage_catalogClear() |
| 115 | + mutator = self.mutator("enable_global_auditlog") |
| 116 | + return mutator(self, value) |
0 commit comments