--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/features/alert/__init__.py Tue Apr 03 14:53:57 2018 +0200
@@ -0,0 +1,72 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+from persistent import Persistent
+
+# import interfaces
+from pyams_content.features.alert.interfaces import IAlertItem, IAlertTarget
+from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION
+from pyams_content.reference.pictograms import IPictogramTable
+from pyams_form.interfaces.form import IFormContextPermissionChecker
+
+# import packages
+from pyams_sequence.utility import get_reference_target
+from pyams_utils.adapter import adapter_config, ContextAdapter
+from pyams_utils.registry import query_utility
+from pyams_utils.zodb import volatile_property
+from zope.container.contained import Contained
+from zope.interface import implementer
+from zope.schema.fieldproperty import FieldProperty
+
+
+@implementer(IAlertItem)
+class AlertItem(Persistent, Contained):
+ """Alert item persistent class"""
+
+ visible = FieldProperty(IAlertItem['visible'])
+ gravity = FieldProperty(IAlertItem['gravity'])
+ header = FieldProperty(IAlertItem['header'])
+ message = FieldProperty(IAlertItem['message'])
+ reference = FieldProperty(IAlertItem['reference'])
+ _pictogram_name = FieldProperty(IAlertItem['pictogram_name'])
+ start_date = FieldProperty(IAlertItem['start_date'])
+ end_date = FieldProperty(IAlertItem['end_date'])
+ maximum_interval = FieldProperty(IAlertItem['maximum_interval'])
+
+ @property
+ def pictogram_name(self):
+ return self._pictogram_name
+
+ @pictogram_name.setter
+ def pictogram_name(self, value):
+ if value != self._pictogram_name:
+ self._pictogram_name = value
+ del self.pictogram
+
+ @volatile_property
+ def pictogram(self):
+ table = query_utility(IPictogramTable)
+ return table.get(self.pictogram_name)
+
+ def get_target(self):
+ return get_reference_target(self.reference)
+
+
+@adapter_config(context=IAlertItem, provides=IFormContextPermissionChecker)
+class AlertitemPermissionChecker(ContextAdapter):
+ """Alert item permission checker"""
+
+ edit_permission = MANAGE_SITE_ROOT_PERMISSION