# HG changeset patch # User Thierry Florac # Date 1522760037 -7200 # Node ID 174894a2293dda3fb905d1cf38a8062a16fd892b # Parent e60b9a60b5460e19632973ce84081e95229b248b Added alerts diff -r e60b9a60b546 -r 174894a2293d src/pyams_content/features/alert/__init__.py --- /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 +# 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 diff -r e60b9a60b546 -r 174894a2293d src/pyams_content/features/alert/container.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/features/alert/container.py Tue Apr 03 14:53:57 2018 +0200 @@ -0,0 +1,80 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# 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 + +# import interfaces +from pyams_content.features.alert.interfaces import IAlertContainer, IAlertItem, IAlertTarget, ALERT_CONTAINER_KEY +from zope.annotation.interfaces import IAnnotations +from zope.location.interfaces import ISublocations +from zope.traversing.interfaces import ITraversable + +# import packages +from pyams_catalog.utils import index_object +from pyams_utils.adapter import adapter_config, ContextAdapter +from pyams_utils.registry import get_current_registry +from zope.container.ordered import OrderedContainer +from zope.interface import implementer +from zope.lifecycleevent import ObjectCreatedEvent +from zope.location import locate + + +@implementer(IAlertContainer) +class AlertContainer(OrderedContainer): + """Alert container persistent class""" + + last_id = 1 + + def append(self, value, notify=True): + key = str(self.last_id) + if not notify: + # pre-locate alert item to avoid multiple notifications + locate(value, self, key) + self[key] = value + self.last_id += 1 + if not notify: + # make sure that alert item is correctly indexed + index_object(value) + + def get_visible_items(self): + return filter(lambda x: IAlertItem(x).visible, self.values()) + + +@adapter_config(context=IAlertTarget, provides=IAlertContainer) +def alert_container_factory(target): + """Alert container factory""" + annotations = IAnnotations(target) + container = annotations.get(ALERT_CONTAINER_KEY) + if container is None: + container = annotations[ALERT_CONTAINER_KEY] = AlertContainer() + get_current_registry().notify(ObjectCreatedEvent(container)) + locate(container, target, '++alert++') + return container + + +@adapter_config(name='alert', context=IAlertTarget, provides=ITraversable) +class AlertContainerNamespace(ContextAdapter): + """Alert container ++alert++ namespace""" + + def traverse(self, name, furtherpath=None): + return IAlertContainer(self.context) + + +@adapter_config(name='alerts', context=IAlertTarget, provides=ISublocations) +class AlertContainerSublocations(ContextAdapter): + """Alert container sub-locations adapter""" + + def sublocations(self): + return IAlertContainer(self.context).values() diff -r e60b9a60b546 -r 174894a2293d src/pyams_content/features/alert/interfaces.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/features/alert/interfaces.py Tue Apr 03 14:53:57 2018 +0200 @@ -0,0 +1,118 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# 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 collections import OrderedDict + +# import interfaces +from pyams_content.interfaces.container import IOrderedContainer +from pyams_content.reference.pictograms.interfaces import PICTOGRAM_VOCABULARY +from pyams_sequence.interfaces import IInternalReference +from zope.annotation import IAttributeAnnotatable + +# import packages +from pyams_i18n.schema import I18nTextLineField +from pyams_sequence.schema import InternalReference +from zope.container.constraints import containers, contains +from zope.interface import Interface, Attribute +from zope.schema import Bool, Choice, Datetime, Int +from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm + +from pyams_content import _ + + +ALERT_CONTAINER_KEY = 'pyams_content.alerts' + + +ALERT_GRAVITY_NAMES = OrderedDict(( + ('success', _("Success")), + ('info', _("Information")), + ('warning', _("Warning")), + ('danger', _("Danger")) +)) + +ALERT_GRAVITY_VOCABULARY = SimpleVocabulary([SimpleTerm(v, title=t) for v, t in ALERT_GRAVITY_NAMES.items()]) + + +class IAlertItem(IAttributeAnnotatable, IInternalReference): + """Alert item interface""" + + containers('.IAlertContainer') + + visible = Bool(title=_("Visible?"), + description=_("Is this alert visible in front-office?"), + required=True, + default=False) + + gravity = Choice(title=_("Alert gravity"), + description=_("Alert gravity will affect rendered alert style"), + required=True, + default='info', + vocabulary=ALERT_GRAVITY_VOCABULARY) + + header = I18nTextLineField(title=_("Header"), + description=_("Short alert header"), + required=False) + + message = I18nTextLineField(title=_("Message"), + description=_("Alert message"), + required=True) + + reference = InternalReference(title=_("Internal reference"), + description=_("Internal link target reference. You can search a reference using " + "'+' followed by internal number, of by entering text matching " + "content title."), + required=False) + + pictogram_name = Choice(title=_("Pictogram"), + description=_("Name of the pictogram to select"), + required=False, + vocabulary=PICTOGRAM_VOCABULARY) + + pictogram = Attribute("Selected pictogram object") + + start_date = Datetime(title=_("Display start date"), + description=_("First date at which alert should be displayed"), + required=False) + + end_date = Datetime(title=_("Display end date"), + description=_("Last date at which alert should be displayed"), + required=False) + + maximum_interval = Int(title=_("Maximum interval"), + description=_("Maximum interval between alert displays on a given device, " + "given in hours; set to 0 to always display the alert"), + required=True, + min=0, + default=48) + + def get_target(self): + """Get internal reference target""" + + +class IAlertContainer(IOrderedContainer): + """Alert container interface""" + + contains(IAlertItem) + + def append(self, value, notify=True): + """Append given value to container""" + + def get_visible_items(self): + """Get list of visible items""" + + +class IAlertTarget(Interface): + """Alert container target interface""" diff -r e60b9a60b546 -r 174894a2293d src/pyams_content/features/alert/zmi/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/features/alert/zmi/__init__.py Tue Apr 03 14:53:57 2018 +0200 @@ -0,0 +1,111 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# 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 + +# import interfaces +from pyams_content.features.alert.interfaces import IAlertTarget, IAlertItem, IAlertContainer +from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION +from pyams_skin.interfaces.viewlet import IWidgetTitleViewletManager +from pyams_skin.layer import IPyAMSLayer + +# import packages +from pyams_content.features.alert import AlertItem +from pyams_content.features.alert.zmi.container import AlertContainerView, AlertContainerTable +from pyams_form.form import AJAXAddForm, AJAXEditForm +from pyams_pagelet.pagelet import pagelet_config +from pyams_skin.viewlet.toolbar import ToolbarAction +from pyams_utils.traversing import get_parent +from pyams_utils.url import absolute_url +from pyams_viewlet.viewlet import viewlet_config +from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm +from pyramid.view import view_config +from z3c.form import field + +from pyams_content import _ + + +@viewlet_config(name='add-alert.action', context=IAlertTarget, layer=IPyAMSLayer, view=AlertContainerView, + manager=IWidgetTitleViewletManager, permission=MANAGE_SITE_ROOT_PERMISSION, weight=1) +class AlertItemAddAction(ToolbarAction): + """Alert item add action""" + + label = _("Add alert") + label_css_class = 'fa fa-fw fa-plus' + url = 'add-alert.html' + modal_target = True + + +@pagelet_config(name='add-alert.html', context=IAlertTarget, layer=IPyAMSLayer, permission=MANAGE_SITE_ROOT_PERMISSION) +class AlertItemAddForm(AdminDialogAddForm): + """Alert item add form""" + + legend = _("Add new alert") + icon_css_class = 'fa fa-fw fa-exclamation-triangle' + + fields = field.Fields(IAlertItem).omit('__parent__', '__name__', 'visible') + ajax_handler = 'add-alert.json' + edit_permission = MANAGE_SITE_ROOT_PERMISSION + + def create(self, data): + return AlertItem() + + def add(self, object): + IAlertContainer(self.context).append(object) + + def nextURL(self): + return absolute_url(self.context, self.request, 'alerts.html') + + +@view_config(name='add-alert.json', context=IAlertTarget, request_type=IPyAMSLayer, + permission=MANAGE_SITE_ROOT_PERMISSION, renderer='json', xhr=True) +class AlertItemAJAXAddForm(AJAXAddForm, AlertItemAddForm): + """Alert item add form, JSON renderer""" + + +@pagelet_config(name='properties.html', context=IAlertItem, layer=IPyAMSLayer, permission=MANAGE_SITE_ROOT_PERMISSION) +class AlertItemPropertiesEditForm(AdminDialogEditForm): + """Alert item properties edit form""" + + legend = _("Edit alert properties") + icon_css_class = 'fa fa-fw fa-exclamation-triangle' + + fields = field.Fields(IAlertItem).omit('__parent__', '__name__', 'visible') + ajax_handler = 'properties.json' + edit_permission = MANAGE_SITE_ROOT_PERMISSION + + +@view_config(name='properties.json', context=IAlertItem, request_type=IPyAMSLayer, + permission=MANAGE_SITE_ROOT_PERMISSION, renderer='json', xhr=True) +class AlertItemPropertiesAJAXEditForm(AJAXEditForm, AlertItemPropertiesEditForm): + """Alert item properties edit form, JSON renderer""" + + def get_ajax_output(self, changes): + output = super(AlertItemPropertiesAJAXEditForm, self).get_ajax_output(changes) + updated = changes.get(IAlertItem, ()) + if updated: + target = get_parent(self.context, IAlertTarget) + table = AlertContainerTable(target, self.request) + table.update() + row = table.setUpRow(self.context) + output.setdefault('events', []).append({ + 'event': 'myams.refresh', + 'options': { + 'handler': 'MyAMS.skin.refreshRow', + 'object_id': 'alert_{0}'.format(self.context.__name__), + 'row': table.renderRow(row) + } + }) + return output diff -r e60b9a60b546 -r 174894a2293d src/pyams_content/features/alert/zmi/container.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/features/alert/zmi/container.py Tue Apr 03 14:53:57 2018 +0200 @@ -0,0 +1,242 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# 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 +import json + +# import interfaces +from pyams_content.features.alert.interfaces import IAlertTarget, IAlertContainer +from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION +from pyams_i18n.interfaces import II18n +from pyams_skin.interfaces import IPageHeader +from pyams_skin.layer import IPyAMSLayer +from pyams_zmi.interfaces.menu import ISiteManagementMenu +from pyams_zmi.layer import IAdminLayer +from z3c.table.interfaces import IValues, IColumn + +# import packages +from pyams_content.skin import pyams_content +from pyams_i18n.column import I18nAttrColumn +from pyams_pagelet.pagelet import pagelet_config +from pyams_skin.page import DefaultPageHeaderAdapter +from pyams_skin.table import BaseTable, SorterColumn, JsActionColumn, I18nColumn, TrashColumn +from pyams_skin.viewlet.menu import MenuItem +from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter +from pyams_utils.fanstatic import get_resource_path +from pyams_utils.text import get_text_start +from pyams_utils.url import absolute_url +from pyams_viewlet.viewlet import viewlet_config +from pyams_zmi.view import ContainerAdminView +from pyramid.decorator import reify +from pyramid.exceptions import NotFound +from pyramid.view import view_config +from z3c.table.column import GetAttrColumn + +from pyams_content import _ + + +@viewlet_config(name='alerts.menu', context=IAlertTarget, layer=IPyAMSLayer, manager=ISiteManagementMenu, + permission=MANAGE_SITE_ROOT_PERMISSION, weight=4) +class AlertsMenu(MenuItem): + """Alerts menu""" + + label = _("Alerts") + icon_class = 'fa-exclamation-triangle' + url = '#alerts.html' + + +class AlertContainerTable(BaseTable): + """Alerts container table""" + + id = 'alerts_table' + hide_header = True + sortOn = None + + cssClasses = {'table': 'table table-bordered table-striped table-hover table-tight table-dnd'} + + @property + def data_attributes(self): + attributes = super(AlertContainerTable, self).data_attributes + attributes.setdefault('table', {}).update({ + 'id': self.id, + 'data-ams-plugins': 'pyams_content', + 'data-ams-plugin-pyams_content-src': get_resource_path(pyams_content), + 'data-ams-location': absolute_url(IAlertContainer(self.context), self.request), + 'data-ams-tablednd-drag-handle': 'td.sorter', + 'data-ams-tablednd-drop-target': 'set-alerts-order.json' + }) + attributes.setdefault('tr', {}).update({ + 'id': lambda x, col: 'alert_{0}'.format(x.__name__), + 'data-ams-delete-target': 'delete-alert.json' + }) + return attributes + + @reify + def values(self): + return list(super(AlertContainerTable, self).values) + + def render(self): + if not self.values: + translate = self.request.localizer.translate + return translate(_("No currently defined alert.")) + return super(AlertContainerTable, self).render() + + +@adapter_config(context=(IAlertTarget, IPyAMSLayer, AlertContainerTable), provides=IValues) +class AlertContainerValues(ContextRequestViewAdapter): + """Alerts container values""" + + @property + def values(self): + return IAlertContainer(self.context).values() + + +@adapter_config(name='sorter', context=(IAlertTarget, IPyAMSLayer, AlertContainerTable), provides=IColumn) +class AlertContainerSorterColumn(SorterColumn): + """Alert container sorter column""" + + +@view_config(name='set-alerts-order.json', context=IAlertContainer, request_type=IPyAMSLayer, + permission=MANAGE_SITE_ROOT_PERMISSION, renderer='json', xhr=True) +def set_alerts_order(request): + """Update alerts order""" + order = list(map(str, json.loads(request.params.get('names')))) + request.context.updateOrder(order) + return {'status': 'success'} + + +@adapter_config(name='show-hide', context=(IAlertTarget, IPyAMSLayer, AlertContainerTable), provides=IColumn) +class AlertContainerShowHideColumn(JsActionColumn): + """Alert container visibility switcher column""" + + cssClasses = {'th': 'action', + 'td': 'action switcher'} + + icon_class = 'fa fa-fw fa-eye' + icon_hint = _("Switch alert visibility") + + url = 'PyAMS_content.alerts.switchVisibility' + + weight = 5 + + def get_icon_class(self, item): + if item.visible: + return self.icon_class + else: + return 'fa fa-fw fa-eye-slash text-danger' + + +@view_config(name='set-alert-visibility.json', context=IAlertContainer, request_type=IPyAMSLayer, + permission=MANAGE_SITE_ROOT_PERMISSION, renderer='json', xhr=True) +def set_alert_visibility(request): + """Set alert visibility""" + container = IAlertContainer(request.context) + alert = container.get(str(request.params.get('object_name'))) + if alert is None: + raise NotFound() + alert.visible = not alert.visible + return {'visible': alert.visible} + + +@adapter_config(name='pictogram', context=(IAlertTarget, IPyAMSLayer, AlertContainerTable), provides=IColumn) +class AlertContainerPictogramColumn(GetAttrColumn): + """Alert container pictogram image column""" + + header = '' + weight = 10 + + cssClasses = {'td': 'text-center width-50'} + dt_sortable = 'false' + + def getValue(self, obj): + pictogram = obj.pictogram + if pictogram is not None: + image = II18n(pictogram).query_attribute('image', request=self.request) + if image: + return ''.format(absolute_url(image, self.request, '++thumb++32x32')) + return '--' + + +@adapter_config(name='header', context=(IAlertTarget, IPyAMSLayer, AlertContainerTable), provides=IColumn) +class AlertContainerHeaderColumn(I18nColumn, I18nAttrColumn): + """Alert container header column""" + + _header = _("Header") + attrName = 'header' + weight = 20 + + def getValue(self, obj): + return super(AlertContainerHeaderColumn, self).getValue(obj) or '--' + + +@adapter_config(name='name', context=(IAlertTarget, IPyAMSLayer, AlertContainerTable), provides=IColumn) +class AlertContainerNameColumn(I18nColumn, I18nAttrColumn): + """Alert container message column""" + + _header = _("Message") + attrName = 'message' + weight = 30 + + def getValue(self, obj): + value = super(AlertContainerNameColumn, self).getValue(obj) + if not value: + return '--' + return get_text_start(value, 50, 10) + + +@adapter_config(name='trash', context=(IAlertTarget, IPyAMSLayer, AlertContainerTable), provides=IColumn) +class AlertContainerTrashColumn(TrashColumn): + """Alert container trash column""" + + +@view_config(name='delete-alert.json', context=IAlertTarget, request_type=IPyAMSLayer, + permission=MANAGE_SITE_ROOT_PERMISSION, renderer='json', xhr=True) +def delete_alert(request): + """Delete alert""" + translate = request.localizer.translate + name = request.params.get('object_name') + if not name: + return { + 'status': 'message', + 'messagebox': { + 'status': 'error', + 'content': translate(_("No provided object_name argument!")) + } + } + if name not in request.context: + return { + 'status': 'message', + 'messagebox': { + 'status': 'error', + 'content': translate(_("Given alert name doesn't exist!")) + } + } + del request.context[name] + return {'status': 'success'} + + +@pagelet_config(name='alerts.html', context=IAlertTarget, layer=IPyAMSLayer, permission=MANAGE_SITE_ROOT_PERMISSION) +class AlertContainerView(ContainerAdminView): + """Alerts container view""" + + title = _("Alert list") + table_class = AlertContainerTable + + +@adapter_config(context=(IAlertTarget, IAdminLayer, AlertContainerView), provides=IPageHeader) +class AlertContainerViewHeaderAdapter(DefaultPageHeaderAdapter): + """Alerts container view header adapter""" + + icon_class = 'fa fa-fw fa-exclamation-triangle' diff -r e60b9a60b546 -r 174894a2293d src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.mo Binary file src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.mo has changed diff -r e60b9a60b546 -r 174894a2293d src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po --- a/src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po Tue Apr 03 12:46:09 2018 +0200 +++ b/src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po Tue Apr 03 14:53:57 2018 +0200 @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE 1.0\n" -"POT-Creation-Date: 2018-03-23 11:00+0100\n" +"POT-Creation-Date: 2018-04-03 14:35+0200\n" "PO-Revision-Date: 2015-09-10 10:42+0200\n" "Last-Translator: Thierry Florac \n" "Language-Team: French\n" @@ -115,7 +115,8 @@ #: src/pyams_content/shared/common/zmi/types.py:457 #: src/pyams_content/shared/imagemap/zmi/container.py:169 #: src/pyams_content/shared/site/zmi/container.py:573 -#: src/pyams_content/root/zmi/sites.py:195 +#: src/pyams_content/root/zmi/sites.py:197 +#: src/pyams_content/features/alert/zmi/container.py:215 msgid "No provided object_name argument!" msgstr "Argument 'object_name' non fourni !" @@ -629,6 +630,8 @@ #: src/pyams_content/component/paragraph/header.py:47 #: src/pyams_content/component/paragraph/interfaces/header.py:40 +#: src/pyams_content/features/alert/interfaces.py:65 +#: src/pyams_content/features/alert/zmi/container.py:176 msgid "Header" msgstr "Chapô" @@ -679,7 +682,6 @@ msgstr "Le jalon a été ajouté." #: src/pyams_content/component/paragraph/zmi/milestone.py:357 -#: src/pyams_content/component/paragraph/zmi/pictogram.py:371 #: src/pyams_content/component/association/zmi/__init__.py:292 msgid "Given association name doesn't exist!" msgstr "Le nom d'association indiqué n'existe pas !" @@ -841,6 +843,10 @@ msgid "Pictogram was correctly added" msgstr "Le pictogramme a été ajouté." +#: src/pyams_content/component/paragraph/zmi/pictogram.py:371 +msgid "Given pictogram name doesn't exist!" +msgstr "Le pictogramme indiqué n'existe pas !" + #: src/pyams_content/component/paragraph/zmi/frame.py:84 msgid "Framed text..." msgstr "Encadré" @@ -865,27 +871,27 @@ msgid "Edit verbatim paragraph properties" msgstr "Propriétés du verbatim" -#: src/pyams_content/component/paragraph/zmi/html.py:77 +#: src/pyams_content/component/paragraph/zmi/html.py:78 msgid "Raw HTML..." msgstr "Code HTML" -#: src/pyams_content/component/paragraph/zmi/html.py:88 +#: src/pyams_content/component/paragraph/zmi/html.py:89 msgid "Add new raw HTML paragraph" msgstr "Ajout d'un paragraphe de code HTML" -#: src/pyams_content/component/paragraph/zmi/html.py:121 +#: src/pyams_content/component/paragraph/zmi/html.py:122 msgid "Edit raw HTML paragraph properties" msgstr "Propriétés du code HTML" -#: src/pyams_content/component/paragraph/zmi/html.py:192 +#: src/pyams_content/component/paragraph/zmi/html.py:193 msgid "Rich text..." msgstr "Texte enrichi" -#: src/pyams_content/component/paragraph/zmi/html.py:203 +#: src/pyams_content/component/paragraph/zmi/html.py:204 msgid "Add new rich text paragraph" msgstr "Ajout d'un paragraphe de texte enrichi" -#: src/pyams_content/component/paragraph/zmi/html.py:236 +#: src/pyams_content/component/paragraph/zmi/html.py:237 msgid "Edit rich text paragraph properties" msgstr "Propriétés du paragraphe de texte enrichi" @@ -919,6 +925,7 @@ #: src/pyams_content/component/association/interfaces/__init__.py:43 #: src/pyams_content/shared/form/interfaces/__init__.py:86 #: src/pyams_content/shared/site/interfaces/__init__.py:107 +#: src/pyams_content/features/alert/interfaces.py:54 msgid "Visible?" msgstr "Visible ?" @@ -1011,10 +1018,12 @@ #: src/pyams_content/component/paragraph/interfaces/pictogram.py:47 #: src/pyams_content/shared/common/interfaces/types.py:67 +#: src/pyams_content/features/alert/interfaces.py:79 msgid "Pictogram" msgstr "Pictogramme" #: src/pyams_content/component/paragraph/interfaces/pictogram.py:48 +#: src/pyams_content/features/alert/interfaces.py:80 msgid "Name of the pictogram to select" msgstr "Sélection du pictogramme à afficher" @@ -1026,8 +1035,8 @@ msgid "" "Alternate pictogram label; if not specified, the pictogram title will be used" msgstr "" -"Libellé de substitution utilisé par le pictogramme; si rien n'est spécifié, le titre " -"du pictogramme sélectionné sera utilisé." +"Libellé de substitution utilisé par le pictogramme; si rien n'est spécifié, " +"le titre du pictogramme sélectionné sera utilisé." #: src/pyams_content/component/paragraph/interfaces/pictogram.py:59 msgid "Associated text" @@ -3171,21 +3180,21 @@ #: src/pyams_content/shared/news/zmi/__init__.py:44 msgid "This news topic" -msgstr "Cette brève" +msgstr "Cette actualité" #: src/pyams_content/shared/news/zmi/__init__.py:63 #: src/pyams_content/shared/news/zmi/__init__.py:74 msgid "Add news topic" -msgstr "Ajouter une brève" +msgstr "Ajouter une actualité" #: src/pyams_content/shared/news/zmi/__init__.py:54 #, python-format msgid "News topic « {title} »" -msgstr "Brève « {title} »" +msgstr "Actualité « {title} »" #: src/pyams_content/shared/news/interfaces/__init__.py:28 msgid "News topic" -msgstr "Brève" +msgstr "Actualité" #: src/pyams_content/shared/view/zmi/properties.py:38 msgid "Main view settings" @@ -3466,6 +3475,7 @@ msgstr "Liste des zones cliquables définies sur l'image" #: src/pyams_content/shared/imagemap/interfaces/__init__.py:93 +#: src/pyams_content/features/alert/interfaces.py:73 msgid "Internal reference" msgstr "Référence interne" @@ -3525,7 +3535,7 @@ msgid "Rent existing content" msgstr "Lier un contenu existant" -#: src/pyams_content/shared/site/zmi/link.py:139 +#: src/pyams_content/shared/site/zmi/link.py:140 msgid "Edit content link properties" msgstr "Propriétés du lien" @@ -3681,16 +3691,16 @@ msgid "Logos template" msgstr "Mode de rendu" -#: src/pyams_content/shared/blog/zmi/__init__.py:49 +#: src/pyams_content/shared/blog/zmi/__init__.py:52 msgid "This blog post" msgstr "Cet article" -#: src/pyams_content/shared/blog/zmi/__init__.py:68 -#: src/pyams_content/shared/blog/zmi/__init__.py:78 +#: src/pyams_content/shared/blog/zmi/__init__.py:71 +#: src/pyams_content/shared/blog/zmi/__init__.py:81 msgid "Add blog post" msgstr "Ajouter un article" -#: src/pyams_content/shared/blog/zmi/__init__.py:59 +#: src/pyams_content/shared/blog/zmi/__init__.py:62 #, python-format msgid "Blog post « {title} »" msgstr "Article de blog « {title} »" @@ -3752,7 +3762,7 @@ msgid "Delete shared site" msgstr "Supprimer ce site" -#: src/pyams_content/root/zmi/sites.py:199 +#: src/pyams_content/root/zmi/sites.py:205 msgid "Given site name doesn't exist!" msgstr "Le nom de site indiqué n'existe pas !" @@ -4265,6 +4275,116 @@ msgid "preview" msgstr "aperçu" +#: src/pyams_content/features/alert/interfaces.py:40 +msgid "Success" +msgstr "Levée d'alerte" + +#: src/pyams_content/features/alert/interfaces.py:41 +msgid "Information" +msgstr "Information" + +#: src/pyams_content/features/alert/interfaces.py:42 +msgid "Warning" +msgstr "Avertissement" + +#: src/pyams_content/features/alert/interfaces.py:43 +msgid "Danger" +msgstr "Danger !" + +#: src/pyams_content/features/alert/interfaces.py:55 +msgid "Is this alert visible in front-office?" +msgstr "Si 'non', cette alerte ne sera pas présentée aux internautes" + +#: src/pyams_content/features/alert/interfaces.py:59 +msgid "Alert gravity" +msgstr "Niveau de gravité" + +#: src/pyams_content/features/alert/interfaces.py:60 +msgid "Alert gravity will affect rendered alert style" +msgstr "Le niveau de gravité chosi affectera le style de rendu de l'alerte" + +#: src/pyams_content/features/alert/interfaces.py:66 +msgid "Short alert header" +msgstr "En-tête de l'alerte" + +#: src/pyams_content/features/alert/interfaces.py:69 +#: src/pyams_content/features/alert/zmi/container.py:188 +msgid "Message" +msgstr "Message" + +#: src/pyams_content/features/alert/interfaces.py:70 +msgid "Alert message" +msgstr "Le message d'alerte doit être assez court et explicite" + +#: src/pyams_content/features/alert/interfaces.py:74 +msgid "" +"Internal link target reference. You can search a reference using '+' " +"followed by internal number, of by entering text matching content title." +msgstr "" +"Référence interne vers la cible du lien. Vous pouvez la rechercher par des " +"mots de son titre, ou par son numéro interne (précédé d'un '+') ; le titre " +"d'origine peut être modifié en utilisant le titre de substitution." + +#: src/pyams_content/features/alert/interfaces.py:86 +msgid "Display start date" +msgstr "Date d'affichage" + +#: src/pyams_content/features/alert/interfaces.py:87 +msgid "First date at which alert should be displayed" +msgstr "Première date à laquelle l'alerte sera affichée. Laissez la zone vide pour qu'elle soit affichée immédiatement." + +#: src/pyams_content/features/alert/interfaces.py:90 +msgid "Display end date" +msgstr "Date de retrait" + +#: src/pyams_content/features/alert/interfaces.py:91 +msgid "Last date at which alert should be displayed" +msgstr "Dernière date à laquelle l'alerte sera affichée. Laissez la zone vide pour qu'elle ne soit pas retirée." + +#: src/pyams_content/features/alert/interfaces.py:94 +msgid "Maximum interval" +msgstr "Intervalle d'affichage" + +#: src/pyams_content/features/alert/interfaces.py:95 +msgid "" +"Maximum interval between alert displays on a given device, given in hours; " +"set to 0 to always display the alert" +msgstr "" +"Cet intervalle est donnée en heures ; passé ce délai, pour un internaute donné, l'alerte apparaîtra à nouveau. " +"Si aucun intervalle n'est indiqué, l'alerte s'affichera en permanence." + +#: src/pyams_content/features/alert/zmi/__init__.py:45 +msgid "Add alert" +msgstr "Ajouter une alerte" + +#: src/pyams_content/features/alert/zmi/__init__.py:55 +msgid "Add new alert" +msgstr "Ajout d'une alerte" + +#: src/pyams_content/features/alert/zmi/__init__.py:82 +msgid "Edit alert properties" +msgstr "Propriétés de l'alerte" + +#: src/pyams_content/features/alert/zmi/container.py:55 +msgid "Alerts" +msgstr "Alertes" + +#: src/pyams_content/features/alert/zmi/container.py:128 +msgid "Switch alert visibility" +msgstr "Cliquez pour rendre l'alerte visible ou non" + +#: src/pyams_content/features/alert/zmi/container.py:234 +msgid "Alert list" +msgstr "Liste des alertes" + +#: src/pyams_content/features/alert/zmi/container.py:93 +msgid "No currently defined alert." +msgstr "Aucune alerte n'est définie actuellement." + +#: src/pyams_content/features/alert/zmi/container.py:223 +msgid "Given alert name doesn't exist!" +msgstr "L'alerte indiquée n'existe pas !" + #: src/pyams_content/features/review/__init__.py:186 #, python-format msgid "Request comment: {comment}" @@ -4534,14 +4654,6 @@ #~ msgid "internal reference target is not published" #~ msgstr "l'image cliquable référencée n'est pas publiée" -#~ msgid "" -#~ "Internal link target reference. You can search a reference using '+' " -#~ "followed by internal number, of by entering text matching content title." -#~ msgstr "" -#~ "Référence interne vers la cible du lien. Vous pouvez la rechercher par " -#~ "des mots de son titre, ou par son numéro interne (précédé d'un '+') ; le " -#~ "titre d'origine peut être modifié en utilisant le titre de substitution." - #~ msgid "Image style" #~ msgstr "Style de l'illustration" @@ -4664,9 +4776,6 @@ #~ msgid "Edit galleries links" #~ msgstr "Galeries d'images associées" -#~ msgid "No currently defined gallery." -#~ msgstr "Aucune galerie d'images associée à ce contenu." - #~ msgid "Visible gallery?" #~ msgstr "Galerie visible ?" @@ -4736,9 +4845,6 @@ #~ msgid "About this version" #~ msgstr "À propos de cette version" -#~ msgid "Display first version date" -#~ msgstr "Date de publication de la première version" - #~ msgid "Display current version date" #~ msgstr "Date de publication de cette version" diff -r e60b9a60b546 -r 174894a2293d src/pyams_content/locales/pyams_content.pot --- a/src/pyams_content/locales/pyams_content.pot Tue Apr 03 12:46:09 2018 +0200 +++ b/src/pyams_content/locales/pyams_content.pot Tue Apr 03 14:53:57 2018 +0200 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE 1.0\n" -"POT-Creation-Date: 2018-03-23 11:00+0100\n" +"POT-Creation-Date: 2018-04-03 14:35+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" @@ -116,7 +116,8 @@ #: ./src/pyams_content/shared/common/zmi/types.py:457 #: ./src/pyams_content/shared/imagemap/zmi/container.py:169 #: ./src/pyams_content/shared/site/zmi/container.py:573 -#: ./src/pyams_content/root/zmi/sites.py:195 +#: ./src/pyams_content/root/zmi/sites.py:197 +#: ./src/pyams_content/features/alert/zmi/container.py:215 msgid "No provided object_name argument!" msgstr "" @@ -602,6 +603,8 @@ #: ./src/pyams_content/component/paragraph/header.py:47 #: ./src/pyams_content/component/paragraph/interfaces/header.py:40 +#: ./src/pyams_content/features/alert/interfaces.py:65 +#: ./src/pyams_content/features/alert/zmi/container.py:176 msgid "Header" msgstr "" @@ -652,7 +655,6 @@ msgstr "" #: ./src/pyams_content/component/paragraph/zmi/milestone.py:357 -#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:371 #: ./src/pyams_content/component/association/zmi/__init__.py:292 msgid "Given association name doesn't exist!" msgstr "" @@ -802,6 +804,10 @@ msgid "Pictogram was correctly added" msgstr "" +#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:371 +msgid "Given pictogram name doesn't exist!" +msgstr "" + #: ./src/pyams_content/component/paragraph/zmi/frame.py:84 msgid "Framed text..." msgstr "" @@ -826,27 +832,27 @@ msgid "Edit verbatim paragraph properties" msgstr "" -#: ./src/pyams_content/component/paragraph/zmi/html.py:77 +#: ./src/pyams_content/component/paragraph/zmi/html.py:78 msgid "Raw HTML..." msgstr "" -#: ./src/pyams_content/component/paragraph/zmi/html.py:88 +#: ./src/pyams_content/component/paragraph/zmi/html.py:89 msgid "Add new raw HTML paragraph" msgstr "" -#: ./src/pyams_content/component/paragraph/zmi/html.py:121 +#: ./src/pyams_content/component/paragraph/zmi/html.py:122 msgid "Edit raw HTML paragraph properties" msgstr "" -#: ./src/pyams_content/component/paragraph/zmi/html.py:192 +#: ./src/pyams_content/component/paragraph/zmi/html.py:193 msgid "Rich text..." msgstr "" -#: ./src/pyams_content/component/paragraph/zmi/html.py:203 +#: ./src/pyams_content/component/paragraph/zmi/html.py:204 msgid "Add new rich text paragraph" msgstr "" -#: ./src/pyams_content/component/paragraph/zmi/html.py:236 +#: ./src/pyams_content/component/paragraph/zmi/html.py:237 msgid "Edit rich text paragraph properties" msgstr "" @@ -880,6 +886,7 @@ #: ./src/pyams_content/component/association/interfaces/__init__.py:43 #: ./src/pyams_content/shared/form/interfaces/__init__.py:86 #: ./src/pyams_content/shared/site/interfaces/__init__.py:107 +#: ./src/pyams_content/features/alert/interfaces.py:54 msgid "Visible?" msgstr "" @@ -966,10 +973,12 @@ #: ./src/pyams_content/component/paragraph/interfaces/pictogram.py:47 #: ./src/pyams_content/shared/common/interfaces/types.py:67 +#: ./src/pyams_content/features/alert/interfaces.py:79 msgid "Pictogram" msgstr "" #: ./src/pyams_content/component/paragraph/interfaces/pictogram.py:48 +#: ./src/pyams_content/features/alert/interfaces.py:80 msgid "Name of the pictogram to select" msgstr "" @@ -3271,6 +3280,7 @@ msgstr "" #: ./src/pyams_content/shared/imagemap/interfaces/__init__.py:93 +#: ./src/pyams_content/features/alert/interfaces.py:73 msgid "Internal reference" msgstr "" @@ -3326,7 +3336,7 @@ msgid "Rent existing content" msgstr "" -#: ./src/pyams_content/shared/site/zmi/link.py:139 +#: ./src/pyams_content/shared/site/zmi/link.py:140 msgid "Edit content link properties" msgstr "" @@ -3480,16 +3490,16 @@ msgid "Logos template" msgstr "" -#: ./src/pyams_content/shared/blog/zmi/__init__.py:49 +#: ./src/pyams_content/shared/blog/zmi/__init__.py:52 msgid "This blog post" msgstr "" -#: ./src/pyams_content/shared/blog/zmi/__init__.py:68 -#: ./src/pyams_content/shared/blog/zmi/__init__.py:78 +#: ./src/pyams_content/shared/blog/zmi/__init__.py:71 +#: ./src/pyams_content/shared/blog/zmi/__init__.py:81 msgid "Add blog post" msgstr "" -#: ./src/pyams_content/shared/blog/zmi/__init__.py:59 +#: ./src/pyams_content/shared/blog/zmi/__init__.py:62 #, python-format msgid "Blog post « {title} »" msgstr "" @@ -3551,7 +3561,7 @@ msgid "Delete shared site" msgstr "" -#: ./src/pyams_content/root/zmi/sites.py:199 +#: ./src/pyams_content/root/zmi/sites.py:205 msgid "Given site name doesn't exist!" msgstr "" @@ -4057,6 +4067,111 @@ msgid "preview" msgstr "" +#: ./src/pyams_content/features/alert/interfaces.py:40 +msgid "Success" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:41 +msgid "Information" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:42 +msgid "Warning" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:43 +msgid "Danger" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:55 +msgid "Is this alert visible in front-office?" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:59 +msgid "Alert gravity" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:60 +msgid "Alert gravity will affect rendered alert style" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:66 +msgid "Short alert header" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:69 +#: ./src/pyams_content/features/alert/zmi/container.py:188 +msgid "Message" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:70 +msgid "Alert message" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:74 +msgid "" +"Internal link target reference. You can search a reference using '+' followed" +" by internal number, of by entering text matching content title." +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:86 +msgid "Display start date" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:87 +msgid "First date at which alert should be displayed" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:90 +msgid "Display end date" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:91 +msgid "Last date at which alert should be displayed" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:94 +msgid "Maximum interval" +msgstr "" + +#: ./src/pyams_content/features/alert/interfaces.py:95 +msgid "" +"Maximum interval between alert displays on a given device, given in hours; " +"set to 0 to always display the alert" +msgstr "" + +#: ./src/pyams_content/features/alert/zmi/__init__.py:45 +msgid "Add alert" +msgstr "" + +#: ./src/pyams_content/features/alert/zmi/__init__.py:55 +msgid "Add new alert" +msgstr "" + +#: ./src/pyams_content/features/alert/zmi/__init__.py:82 +msgid "Edit alert properties" +msgstr "" + +#: ./src/pyams_content/features/alert/zmi/container.py:55 +msgid "Alerts" +msgstr "" + +#: ./src/pyams_content/features/alert/zmi/container.py:128 +msgid "Switch alert visibility" +msgstr "" + +#: ./src/pyams_content/features/alert/zmi/container.py:234 +msgid "Alert list" +msgstr "" + +#: ./src/pyams_content/features/alert/zmi/container.py:93 +msgid "No currently defined alert." +msgstr "" + +#: ./src/pyams_content/features/alert/zmi/container.py:223 +msgid "Given alert name doesn't exist!" +msgstr "" + #: ./src/pyams_content/features/review/__init__.py:186 #, python-format msgid "Request comment: {comment}" diff -r e60b9a60b546 -r 174894a2293d src/pyams_content/root/__init__.py --- a/src/pyams_content/root/__init__.py Tue Apr 03 12:46:09 2018 +0200 +++ b/src/pyams_content/root/__init__.py Tue Apr 03 14:53:57 2018 +0200 @@ -18,6 +18,7 @@ # import standard library # import interfaces +from pyams_content.features.alert import IAlertTarget from pyams_content.features.preview.interfaces import IPreviewTarget from pyams_content.interfaces import WEBMASTER_ROLE, OPERATOR_ROLE from pyams_content.root.interfaces import ISiteRootRoles, ISiteRootConfiguration, ISiteRoot, \ @@ -43,7 +44,8 @@ from zope.interface import implementer -@implementer(IDefaultProtectionPolicy, ISiteRoot, ISiteRootRoles, IPortalContext, IPreviewTarget) +@implementer(IDefaultProtectionPolicy, ISiteRoot, ISiteRootRoles, IPortalContext, + IAlertTarget, IPreviewTarget) class SiteRoot(ProtectedObject, BaseSiteRoot, UserSkinnableContent): """Main site root"""