--- a/src/pyams_content/component/links/__init__.py Mon Jun 11 17:32:24 2018 +0200
+++ b/src/pyams_content/component/links/__init__.py Tue Jun 12 10:50:18 2018 +0200
@@ -20,6 +20,7 @@
from pyams_content.component.links.interfaces import IBaseLink, IInternalLink, IExternalLink, IMailtoLink
from pyams_content.features.checker.interfaces import IContentChecker, ERROR_VALUE
from pyams_content.interfaces import IBaseContent, MANAGE_CONTENT_PERMISSION
+from pyams_content.reference.pictograms.interfaces import IPictogramTable
from pyams_form.interfaces.form import IFormContextPermissionChecker
from pyams_i18n.interfaces import II18n
from pyams_sequence.interfaces import ISequentialIdInfo
@@ -31,10 +32,12 @@
from pyams_content.workflow import VISIBLE_STATES
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.request import check_request
from pyams_utils.traversing import get_parent
from pyams_utils.url import absolute_url
from pyams_utils.vocabulary import vocabulary_config
+from pyams_utils.zodb import volatile_property
from zope.interface import implementer
from zope.schema.fieldproperty import FieldProperty
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
@@ -69,6 +72,23 @@
title = FieldProperty(IBaseLink['title'])
description = FieldProperty(IBaseLink['description'])
+ _pictogram_name = FieldProperty(IBaseLink['pictogram_name'])
+
+ @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)
+ if table is not None:
+ return table.get(self._pictogram_name)
class BaseLinkInfoAdapter(ContextAdapter):
--- a/src/pyams_content/component/links/interfaces/__init__.py Mon Jun 11 17:32:24 2018 +0200
+++ b/src/pyams_content/component/links/interfaces/__init__.py Tue Jun 12 10:50:18 2018 +0200
@@ -17,11 +17,13 @@
# import interfaces
from pyams_content.component.association.interfaces import IAssociationTarget, IAssociationItem
+from pyams_content.reference.pictograms.interfaces import SELECTED_PICTOGRAM_VOCABULARY
from pyams_sequence.interfaces import IInternalReference
# import packages
from pyams_i18n.schema import I18nTextLineField, I18nTextField
from pyams_utils.schema import MailAddressField
+from zope.interface import Attribute
from zope.schema import Choice, TextLine, URI
from pyams_content import _
@@ -38,6 +40,13 @@
description=_("Link description displayed by front-office template"),
required=False)
+ pictogram_name = Choice(title=_("Pictogram"),
+ description=_("Name of the pictogram associated with this link"),
+ required=False,
+ vocabulary=SELECTED_PICTOGRAM_VOCABULARY)
+
+ pictogram = Attribute("Selected pictogram object")
+
def get_editor_url(self):
"""Get URL for use in HTML editor"""
--- a/src/pyams_content/component/links/zmi/__init__.py Mon Jun 11 17:32:24 2018 +0200
+++ b/src/pyams_content/component/links/zmi/__init__.py Tue Jun 12 10:50:18 2018 +0200
@@ -18,7 +18,7 @@
# import interfaces
from pyams_content.component.association.interfaces import IAssociationContainer
from pyams_content.component.association.zmi.interfaces import IAssociationsView
-from pyams_content.component.links.interfaces import ILinkContainerTarget, IInternalLink, IBaseLink, \
+from pyams_content.component.links.interfaces import ILinkContainerTarget, IBaseLink, IInternalLink, \
IExternalLink, IMailtoLink
from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerTable, IParagraphTitleToolbar
from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
@@ -31,6 +31,7 @@
from pyams_content.component.links import InternalLink, ExternalLink, MailtoLink
from pyams_content.component.paragraph.zmi import get_json_paragraph_markers_refresh_event
from pyams_content.component.paragraph.zmi.container import ParagraphContainerCounterBase
+from pyams_content.reference.pictograms.zmi.widget import PictogramSelectFieldWidget
from pyams_form.form import ajax_config
from pyams_form.security import ProtectedFormObjectMixin
from pyams_pagelet.pagelet import pagelet_config
@@ -86,7 +87,9 @@
legend = _("Add new internal link")
icon_css_class = 'fa fa-fw fa-external-link-square fa-rotate-90'
- fields = field.Fields(IInternalLink).select('reference', 'title', 'description')
+ fields = field.Fields(IInternalLink).select('reference', 'title', 'description', 'pictogram_name')
+ fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
+
edit_permission = MANAGE_CONTENT_PERMISSION
def updateWidgets(self, prefix=None):
@@ -119,7 +122,9 @@
legend = _("Edit internal link properties")
icon_css_class = 'fa fa-fw fa-external-link-square fa-rotate-90'
- fields = field.Fields(IInternalLink).select('reference', 'title', 'description')
+ fields = field.Fields(IInternalLink).select('reference', 'title', 'description', 'pictogram_name')
+ fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
+
edit_permission = None # defined by IFormContextPermissionChecker adapter
def updateWidgets(self, prefix=None):
@@ -179,7 +184,9 @@
legend = _("Add new external link")
icon_css_class = 'fa fa-fw fa-external-link'
- fields = field.Fields(IExternalLink).select('url', 'title', 'description', 'language')
+ fields = field.Fields(IExternalLink).select('url', 'title', 'description', 'pictogram_name', 'language')
+ fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
+
edit_permission = MANAGE_CONTENT_PERMISSION
def updateWidgets(self, prefix=None):
@@ -212,7 +219,9 @@
legend = _("Edit external link properties")
icon_css_class = 'fa fa-fw fa-external-link'
- fields = field.Fields(IExternalLink).select('url', 'title', 'description', 'language')
+ fields = field.Fields(IExternalLink).select('url', 'title', 'description', 'pictogram_name', 'language')
+ fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
+
edit_permission = None # defined by IFormContextPermissionChecker adapter
def updateWidgets(self, prefix=None):
@@ -272,7 +281,9 @@
legend = _("Add new mailto link")
icon_css_class = 'fa fa-fw fa-envelope-o'
- fields = field.Fields(IMailtoLink).select('address', 'address_name', 'title', 'description')
+ fields = field.Fields(IMailtoLink).select('address', 'address_name', 'title', 'description', 'pictogram_name')
+ fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
+
edit_permission = MANAGE_CONTENT_PERMISSION
def updateWidgets(self, prefix=None):
@@ -305,7 +316,9 @@
legend = _("Edit mailto link properties")
icon_css_class = 'fa fa-fw fa-envelope-o'
- fields = field.Fields(IMailtoLink).select('address', 'address_name', 'title', 'description')
+ fields = field.Fields(IMailtoLink).select('address', 'address_name', 'title', 'description', 'pictogram_name')
+ fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
+
edit_permission = None # defined by IFormContextPermissionChecker adapter
def updateWidgets(self, prefix=None):
--- a/src/pyams_content/component/paragraph/pictogram.py Mon Jun 11 17:32:24 2018 +0200
+++ b/src/pyams_content/component/paragraph/pictogram.py Tue Jun 12 10:50:18 2018 +0200
@@ -78,7 +78,8 @@
@volatile_property
def pictogram(self):
table = query_utility(IPictogramTable)
- return table.get(self.pictogram_name)
+ if table is not None:
+ return table.get(self._pictogram_name)
@adapter_config(context=IPictogramItem, provides=IFormContextPermissionChecker)
--- a/src/pyams_content/component/paragraph/zmi/pictogram.py Mon Jun 11 17:32:24 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/pictogram.py Tue Jun 12 10:50:18 2018 +0200
@@ -9,7 +9,6 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
-from pyams_content.reference.pictograms.zmi import get_pictogram_header
__docformat__ = 'restructuredtext'
@@ -24,13 +23,11 @@
from pyams_content.component.paragraph.zmi import IParagraphContainerView, IParagraphEditFormButtons
from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor
from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
-from pyams_content.reference.pictograms.interfaces import IPictogramTable
from pyams_content.shared.common import IWfSharedContent
from pyams_form.interfaces.form import IInnerForm, IInnerSubForm
from pyams_i18n.interfaces import II18n
from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, IWidgetTitleViewletManager
from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces.data import IObjectData
from pyams_zmi.interfaces import IPropertiesEditForm
from z3c.form.interfaces import INPUT_MODE, IDataExtractedEvent
from z3c.table.interfaces import IValues, IColumn
@@ -41,6 +38,7 @@
from pyams_content.component.paragraph.zmi import BaseParagraphAddMenu, BaseParagraphAJAXAddForm, \
BaseParagraphPropertiesEditForm, BaseParagraphAJAXEditForm
from pyams_content.features.renderer.zmi.widget import RendererFieldWidget
+from pyams_content.reference.pictograms.zmi.widget import PictogramSelectFieldWidget
from pyams_form.form import AJAXAddForm, ajax_config
from pyams_form.security import ProtectedFormObjectMixin
from pyams_i18n.column import I18nAttrColumn
@@ -51,7 +49,6 @@
from pyams_skin.table import BaseTable, SorterColumn, I18nColumn, TrashColumn, VisibilitySwitcherColumn
from pyams_skin.viewlet.toolbar import ToolbarAction
from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
-from pyams_utils.registry import query_utility
from pyams_utils.text import get_text_start
from pyams_utils.traversing import get_parent
from pyams_utils.url import absolute_url
@@ -320,26 +317,12 @@
icon_css_class = 'fa fa-fw fa-arrow-h'
fields = field.Fields(IPictogramItem).omit('__parent__', '__name__', 'visible')
+ fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
+
edit_permission = MANAGE_CONTENT_PERMISSION
def updateWidgets(self, prefix=None):
super(PictogramAddForm, self).updateWidgets(prefix)
- if 'pictogram_name' in self.widgets:
- pictograms = query_utility(IPictogramTable)
- if pictograms is not None:
- label_id = '{0}_pictogram_label'.format(self.id)
- widget = self.widgets['pictogram_name']
- widget.after_widget_notice = '<span id="{0}" class="text-info">{1}</span>'.format(
- label_id,
- self.request.localizer.translate(_("Default header: --")))
- widget.object_data = {
- 'ams-change-handler': 'MyAMS.helpers.select2ChangeHelper',
- 'ams-stop-propagation': 'true',
- 'ams-select2-helper-type': 'html',
- 'ams-select2-helper-url': absolute_url(pictograms, self.request, 'get-pictogram-header.html'),
- 'ams-select2-helper-target': '#{0}'.format(label_id)
- }
- alsoProvides(widget, IObjectData)
if 'body' in self.widgets:
self.widgets['body'].widget_css_class = 'textarea height-100'
@@ -376,31 +359,12 @@
icon_css_class = 'fa fa-fw fa-linode'
fields = field.Fields(IPictogramItem).omit('__parent__', '__name__', 'visible')
+ fields['pictogram_name'].widgetFactory = PictogramSelectFieldWidget
+
edit_permission = MANAGE_CONTENT_PERMISSION
def updateWidgets(self, prefix=None):
super(PictogramPropertiesEditForm, self).updateWidgets(prefix)
- if 'pictogram_name' in self.widgets:
- pictograms = query_utility(IPictogramTable)
- if pictograms is not None:
- pictogram = pictograms.get(self.context.pictogram_name)
- label_id = '{0}_pictogram_label'.format(self.id)
- widget = self.widgets['pictogram_name']
- widget.required = True
- if pictogram is None:
- widget.after_widget_notice = '<span id="{0}" class="text-info">--</span>'.format(label_id)
- else:
- widget.after_widget_notice = '<span id="{0}" class="text-info">{1}</span>'.format(
- label_id,
- get_pictogram_header(pictogram, self.request))
- widget.object_data = {
- 'ams-change-handler': 'MyAMS.helpers.select2ChangeHelper',
- 'ams-stop-propagation': 'true',
- 'ams-select2-helper-type': 'html',
- 'ams-select2-helper-url': absolute_url(pictograms, self.request, 'get-pictogram-header.html'),
- 'ams-select2-helper-target': '#{0}'.format(label_id)
- }
- alsoProvides(widget, IObjectData)
if 'body' in self.widgets:
self.widgets['body'].widget_css_class = 'textarea height-100'
Binary file src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.mo has changed
--- a/src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po Mon Jun 11 17:32:24 2018 +0200
+++ b/src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po Tue Jun 12 10:50:18 2018 +0200
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2018-06-11 17:15+0200\n"
+"POT-Creation-Date: 2018-06-12 09:21+0200\n"
"PO-Revision-Date: 2015-09-10 10:42+0200\n"
"Last-Translator: Thierry Florac <tflorac@ulthar.net>\n"
"Language-Team: French\n"
@@ -219,7 +219,7 @@
#: src/pyams_content/component/illustration/interfaces/__init__.py:52
#: src/pyams_content/component/paragraph/interfaces/video.py:48
#: src/pyams_content/component/paragraph/interfaces/audio.py:44
-#: src/pyams_content/component/links/interfaces/__init__.py:37
+#: src/pyams_content/component/links/interfaces/__init__.py:39
#: src/pyams_content/component/video/interfaces/__init__.py:48
#: src/pyams_content/shared/common/interfaces/__init__.py:149
#: src/pyams_content/shared/form/interfaces/__init__.py:66
@@ -401,7 +401,7 @@
msgstr "Type de fichier joint"
#: src/pyams_content/component/extfile/interfaces/__init__.py:36
-#: src/pyams_content/component/links/interfaces/__init__.py:33
+#: src/pyams_content/component/links/interfaces/__init__.py:35
#: src/pyams_content/shared/imagemap/interfaces/__init__.py:54
#: src/pyams_content/shared/site/interfaces/__init__.py:113
msgid "Alternate title"
@@ -419,7 +419,7 @@
msgstr "Description du fichier, présentée aux internautes"
#: src/pyams_content/component/extfile/interfaces/__init__.py:48
-#: src/pyams_content/component/links/interfaces/__init__.py:59
+#: src/pyams_content/component/links/interfaces/__init__.py:68
msgid "Language"
msgstr "Langue"
@@ -536,7 +536,7 @@
msgid "no visible paragraph"
msgstr "aucun bloc de contenu visible"
-#: src/pyams_content/component/paragraph/pictogram.py:134
+#: src/pyams_content/component/paragraph/pictogram.py:135
msgid "Selected pictogram is missing"
msgstr "le pictogramme sélectionné est introuvable"
@@ -712,64 +712,59 @@
"Vérifiez le paramétrage des types de blocs de contenu autorisés pour pouvoir "
"ajouter de nouveaux blocs."
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:84
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:81
msgid "Pictograms..."
msgstr "Pictogrammes"
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:97
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:94
msgid "Add new pictogram paragraph"
msgstr "Ajout de pictogrammes"
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:124
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:121
msgid "Edit pictogram paragraph properties"
msgstr "Propriétés des pictogrammes"
#. Default: Header
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:254
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:251
msgid "pictogram-item-header"
msgstr "En-tête"
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:269
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:266
#: src/pyams_content/component/paragraph/zmi/keynumber.py:260
#: src/pyams_content/component/paragraph/interfaces/pictogram.py:58
#: src/pyams_content/component/paragraph/interfaces/keynumber.py:58
msgid "Associated text"
msgstr "Texte associé"
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:291
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:288
#: src/pyams_content/component/paragraph/interfaces/pictogram.py:80
msgid "Pictograms"
msgstr "Pictogrammes"
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:306
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:303
#: src/pyams_content/reference/pictograms/zmi/__init__.py:62
msgid "Add pictogram"
msgstr "Ajouter un pictogramme"
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:319
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:316
#: src/pyams_content/reference/pictograms/zmi/__init__.py:74
msgid "Add new pictogram"
msgstr "Ajout d'un pictogramme"
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:375
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:358
#: src/pyams_content/reference/pictograms/zmi/__init__.py:98
msgid "Edit pictogram properties"
msgstr "Propriétés du pictogramme"
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:355
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:338
msgid "Pictogram was correctly added"
msgstr "Le pictogramme a été ajouté."
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:365
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:422
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:348
+#: src/pyams_content/component/paragraph/zmi/pictogram.py:386
msgid "You must select a pictogram!"
msgstr "Vous devez sélectionner un pictogramme !"
-#: src/pyams_content/component/paragraph/zmi/pictogram.py:334
-#: src/pyams_content/reference/pictograms/zmi/__init__.py:174
-msgid "Default header: --"
-msgstr "En-tête par défaut : --"
-
#: src/pyams_content/component/paragraph/zmi/audio.py:54
msgid "Audio paragraph..."
msgstr "Bande son"
@@ -1017,6 +1012,7 @@
msgstr "Si 'non', ce pictogramme ne sera pas présenté aux internautes"
#: src/pyams_content/component/paragraph/interfaces/pictogram.py:46
+#: src/pyams_content/component/links/interfaces/__init__.py:43
#: src/pyams_content/shared/common/interfaces/types.py:68
#: src/pyams_content/features/alert/interfaces.py:79
msgid "Pictogram"
@@ -1323,67 +1319,67 @@
msgid "Presentation template used for associations"
msgstr "Modèle de présentation utilisé par ce bloc de contenu"
-#: src/pyams_content/component/links/__init__.py:104
+#: src/pyams_content/component/links/__init__.py:124
msgid "Internal link"
msgstr "Lien interne"
-#: src/pyams_content/component/links/__init__.py:186
+#: src/pyams_content/component/links/__init__.py:206
msgid "External link"
msgstr "Lien externe"
-#: src/pyams_content/component/links/__init__.py:239
+#: src/pyams_content/component/links/__init__.py:259
msgid "Mailto link"
msgstr "Lien mailto"
-#: src/pyams_content/component/links/__init__.py:173
+#: src/pyams_content/component/links/__init__.py:193
msgid "target is not published"
msgstr "le contenu ciblé n'est pas publié"
-#: src/pyams_content/component/links/zmi/__init__.py:57
+#: src/pyams_content/component/links/zmi/__init__.py:58
msgid "Internal links"
msgstr "Liens internes"
-#: src/pyams_content/component/links/zmi/__init__.py:72
+#: src/pyams_content/component/links/zmi/__init__.py:73
msgid "Add internal link"
msgstr "Lien interne"
-#: src/pyams_content/component/links/zmi/__init__.py:86
+#: src/pyams_content/component/links/zmi/__init__.py:87
msgid "Add new internal link"
msgstr "Ajout d'un lien interne"
-#: src/pyams_content/component/links/zmi/__init__.py:119
+#: src/pyams_content/component/links/zmi/__init__.py:122
msgid "Edit internal link properties"
msgstr "Propriétés du lien interne"
-#: src/pyams_content/component/links/zmi/__init__.py:150
+#: src/pyams_content/component/links/zmi/__init__.py:155
msgid "External links"
msgstr "Liens externes"
-#: src/pyams_content/component/links/zmi/__init__.py:165
+#: src/pyams_content/component/links/zmi/__init__.py:170
msgid "Add external link"
msgstr "Lien externe"
-#: src/pyams_content/component/links/zmi/__init__.py:179
+#: src/pyams_content/component/links/zmi/__init__.py:184
msgid "Add new external link"
msgstr "Ajout d'un lien externe"
-#: src/pyams_content/component/links/zmi/__init__.py:212
+#: src/pyams_content/component/links/zmi/__init__.py:219
msgid "Edit external link properties"
msgstr "Propriétés du lien externe"
-#: src/pyams_content/component/links/zmi/__init__.py:243
+#: src/pyams_content/component/links/zmi/__init__.py:252
msgid "Mailto links"
msgstr "Liens mailto"
-#: src/pyams_content/component/links/zmi/__init__.py:258
+#: src/pyams_content/component/links/zmi/__init__.py:267
msgid "Add mailto link"
msgstr "Lien mailto"
-#: src/pyams_content/component/links/zmi/__init__.py:272
+#: src/pyams_content/component/links/zmi/__init__.py:281
msgid "Add new mailto link"
msgstr "Ajout d'un lien « mailto »"
-#: src/pyams_content/component/links/zmi/__init__.py:305
+#: src/pyams_content/component/links/zmi/__init__.py:316
msgid "Edit mailto link properties"
msgstr "Propriétés du lien « mailto »"
@@ -1395,47 +1391,51 @@
msgid "Content's internal links"
msgstr "Autres contenus qui pointent vers ce contenu"
-#: src/pyams_content/component/links/interfaces/__init__.py:34
+#: src/pyams_content/component/links/interfaces/__init__.py:36
msgid "Link title, as shown in front-office"
msgstr ""
"Le contexte d'utilisation de ce lien peut nécessiter de modifier son titre "
"d'origine. Ce titre de substitution sera alors présenté aux internautes."
-#: src/pyams_content/component/links/interfaces/__init__.py:38
+#: src/pyams_content/component/links/interfaces/__init__.py:40
msgid "Link description displayed by front-office template"
msgstr "Description du lien, présentée aux internautes"
-#: src/pyams_content/component/links/interfaces/__init__.py:55
+#: src/pyams_content/component/links/interfaces/__init__.py:44
+msgid "Name of the pictogram associated with this link"
+msgstr "Pictogramme à associer à ce lien"
+
+#: src/pyams_content/component/links/interfaces/__init__.py:64
#: src/pyams_content/shared/logo/interfaces/__init__.py:50
msgid "Target URL"
msgstr "URL cible"
-#: src/pyams_content/component/links/interfaces/__init__.py:56
+#: src/pyams_content/component/links/interfaces/__init__.py:65
#: src/pyams_content/shared/logo/interfaces/__init__.py:51
msgid "URL used to access external resource"
msgstr ""
"URL utilisée pour accéder à cette ressource externe. Doit comprendre le "
"protocole d'accès au site, comme « http:// » ou « https:// »."
-#: src/pyams_content/component/links/interfaces/__init__.py:60
+#: src/pyams_content/component/links/interfaces/__init__.py:69
msgid "Language used in this remote resource"
msgstr ""
"Langue utilisée par cette ressource extene ; à préciser lorsqu'il ne s'agit "
"pas de la langue par défaut du site."
-#: src/pyams_content/component/links/interfaces/__init__.py:68
+#: src/pyams_content/component/links/interfaces/__init__.py:77
msgid "Target address"
msgstr "Adresse mail"
-#: src/pyams_content/component/links/interfaces/__init__.py:69
+#: src/pyams_content/component/links/interfaces/__init__.py:78
msgid "Target email address"
msgstr "Adresse de messagerie \"stricte\", soit uniquement \"xxx@yyy.com\""
-#: src/pyams_content/component/links/interfaces/__init__.py:72
+#: src/pyams_content/component/links/interfaces/__init__.py:81
msgid "Address name"
msgstr "Nom de messagerie"
-#: src/pyams_content/component/links/interfaces/__init__.py:73
+#: src/pyams_content/component/links/interfaces/__init__.py:82
msgid "Address as displayed in address book"
msgstr ""
"Nom de la boîte aux lettres, tel qu'il sera affiché dans l'application de "
@@ -2155,16 +2155,18 @@
"If you use a local template, you can define a whole custom configuration but "
"the template definition can't be reused anywhere..."
msgstr ""
-"Vous pouvez modifier le modèle de présentation qui sera appliqué **par défaut** à "
-"tous les contenus de ce gabarit.\n"
+"Vous pouvez modifier le modèle de présentation qui sera appliqué **par "
+"défaut** à tous les contenus de ce gabarit.\n"
"\n"
-"Si vous choisissez d'utiliser un modèle de présentation partagé, vous pourrez ajuster les "
-"paramètres de chaque composant mais ne pourrez pas modifier la liste des composants ou leur "
-"position et la configuration de la page.\n"
+"Si vous choisissez d'utiliser un modèle de présentation partagé, vous "
+"pourrez ajuster les paramètres de chaque composant mais ne pourrez pas "
+"modifier la liste des composants ou leur position et la configuration de la "
+"page.\n"
"\n"
-"Si vous choisissez d'utiliser un modèle de présentation \"local\", vous pourrez définir "
-"l'ensemble de la configuration mais le modèle de présentation ne pourra pas être réutilisé "
-"ailleurs que dans les contenus de ce gabarit."
+"Si vous choisissez d'utiliser un modèle de présentation \"local\", vous "
+"pourrez définir l'ensemble de la configuration mais le modèle de "
+"présentation ne pourra pas être réutilisé ailleurs que dans les contenus de "
+"ce gabarit."
#: src/pyams_content/shared/common/zmi/portal.py:72
msgid "Override tool default template"
@@ -4483,6 +4485,11 @@
msgid "References"
msgstr "Tables de réf."
+#: src/pyams_content/reference/pictograms/zmi/__init__.py:172
+#: src/pyams_content/reference/pictograms/zmi/widget.py:55
+msgid "Default header: --"
+msgstr "En-tête par défaut : --"
+
#: src/pyams_content/reference/pictograms/zmi/manager.py:51
msgid "Pictograms selection..."
msgstr "Sélection de pictogrammes"
--- a/src/pyams_content/locales/pyams_content.pot Mon Jun 11 17:32:24 2018 +0200
+++ b/src/pyams_content/locales/pyams_content.pot Tue Jun 12 10:50:18 2018 +0200
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2018-06-11 17:15+0200\n"
+"POT-Creation-Date: 2018-06-12 09:21+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -211,7 +211,7 @@
#: ./src/pyams_content/component/illustration/interfaces/__init__.py:52
#: ./src/pyams_content/component/paragraph/interfaces/video.py:48
#: ./src/pyams_content/component/paragraph/interfaces/audio.py:44
-#: ./src/pyams_content/component/links/interfaces/__init__.py:37
+#: ./src/pyams_content/component/links/interfaces/__init__.py:39
#: ./src/pyams_content/component/video/interfaces/__init__.py:48
#: ./src/pyams_content/shared/common/interfaces/__init__.py:149
#: ./src/pyams_content/shared/form/interfaces/__init__.py:66
@@ -388,7 +388,7 @@
msgstr ""
#: ./src/pyams_content/component/extfile/interfaces/__init__.py:36
-#: ./src/pyams_content/component/links/interfaces/__init__.py:33
+#: ./src/pyams_content/component/links/interfaces/__init__.py:35
#: ./src/pyams_content/shared/imagemap/interfaces/__init__.py:54
#: ./src/pyams_content/shared/site/interfaces/__init__.py:113
msgid "Alternate title"
@@ -406,7 +406,7 @@
msgstr ""
#: ./src/pyams_content/component/extfile/interfaces/__init__.py:48
-#: ./src/pyams_content/component/links/interfaces/__init__.py:59
+#: ./src/pyams_content/component/links/interfaces/__init__.py:68
msgid "Language"
msgstr ""
@@ -509,7 +509,7 @@
msgid "no visible paragraph"
msgstr ""
-#: ./src/pyams_content/component/paragraph/pictogram.py:134
+#: ./src/pyams_content/component/paragraph/pictogram.py:135
msgid "Selected pictogram is missing"
msgstr ""
@@ -673,64 +673,59 @@
msgid "Check allowed paragraph types to be able to create new paragraphs."
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:84
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:81
msgid "Pictograms..."
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:97
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:94
msgid "Add new pictogram paragraph"
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:124
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:121
msgid "Edit pictogram paragraph properties"
msgstr ""
#. Default: Header
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:254
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:251
msgid "pictogram-item-header"
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:269
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:266
#: ./src/pyams_content/component/paragraph/zmi/keynumber.py:260
#: ./src/pyams_content/component/paragraph/interfaces/pictogram.py:58
#: ./src/pyams_content/component/paragraph/interfaces/keynumber.py:58
msgid "Associated text"
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:291
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:288
#: ./src/pyams_content/component/paragraph/interfaces/pictogram.py:80
msgid "Pictograms"
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:306
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:303
#: ./src/pyams_content/reference/pictograms/zmi/__init__.py:62
msgid "Add pictogram"
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:319
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:316
#: ./src/pyams_content/reference/pictograms/zmi/__init__.py:74
msgid "Add new pictogram"
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:375
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:358
#: ./src/pyams_content/reference/pictograms/zmi/__init__.py:98
msgid "Edit pictogram properties"
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:355
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:338
msgid "Pictogram was correctly added"
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:365
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:422
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:348
+#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:386
msgid "You must select a pictogram!"
msgstr ""
-#: ./src/pyams_content/component/paragraph/zmi/pictogram.py:334
-#: ./src/pyams_content/reference/pictograms/zmi/__init__.py:174
-msgid "Default header: --"
-msgstr ""
-
#: ./src/pyams_content/component/paragraph/zmi/audio.py:54
msgid "Audio paragraph..."
msgstr ""
@@ -973,6 +968,7 @@
msgstr ""
#: ./src/pyams_content/component/paragraph/interfaces/pictogram.py:46
+#: ./src/pyams_content/component/links/interfaces/__init__.py:43
#: ./src/pyams_content/shared/common/interfaces/types.py:68
#: ./src/pyams_content/features/alert/interfaces.py:79
msgid "Pictogram"
@@ -1272,67 +1268,67 @@
msgid "Presentation template used for associations"
msgstr ""
-#: ./src/pyams_content/component/links/__init__.py:104
+#: ./src/pyams_content/component/links/__init__.py:124
msgid "Internal link"
msgstr ""
-#: ./src/pyams_content/component/links/__init__.py:186
+#: ./src/pyams_content/component/links/__init__.py:206
msgid "External link"
msgstr ""
-#: ./src/pyams_content/component/links/__init__.py:239
+#: ./src/pyams_content/component/links/__init__.py:259
msgid "Mailto link"
msgstr ""
-#: ./src/pyams_content/component/links/__init__.py:173
+#: ./src/pyams_content/component/links/__init__.py:193
msgid "target is not published"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:57
+#: ./src/pyams_content/component/links/zmi/__init__.py:58
msgid "Internal links"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:72
+#: ./src/pyams_content/component/links/zmi/__init__.py:73
msgid "Add internal link"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:86
+#: ./src/pyams_content/component/links/zmi/__init__.py:87
msgid "Add new internal link"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:119
+#: ./src/pyams_content/component/links/zmi/__init__.py:122
msgid "Edit internal link properties"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:150
+#: ./src/pyams_content/component/links/zmi/__init__.py:155
msgid "External links"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:165
+#: ./src/pyams_content/component/links/zmi/__init__.py:170
msgid "Add external link"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:179
+#: ./src/pyams_content/component/links/zmi/__init__.py:184
msgid "Add new external link"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:212
+#: ./src/pyams_content/component/links/zmi/__init__.py:219
msgid "Edit external link properties"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:243
+#: ./src/pyams_content/component/links/zmi/__init__.py:252
msgid "Mailto links"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:258
+#: ./src/pyams_content/component/links/zmi/__init__.py:267
msgid "Add mailto link"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:272
+#: ./src/pyams_content/component/links/zmi/__init__.py:281
msgid "Add new mailto link"
msgstr ""
-#: ./src/pyams_content/component/links/zmi/__init__.py:305
+#: ./src/pyams_content/component/links/zmi/__init__.py:316
msgid "Edit mailto link properties"
msgstr ""
@@ -1344,41 +1340,45 @@
msgid "Content's internal links"
msgstr ""
-#: ./src/pyams_content/component/links/interfaces/__init__.py:34
+#: ./src/pyams_content/component/links/interfaces/__init__.py:36
msgid "Link title, as shown in front-office"
msgstr ""
-#: ./src/pyams_content/component/links/interfaces/__init__.py:38
+#: ./src/pyams_content/component/links/interfaces/__init__.py:40
msgid "Link description displayed by front-office template"
msgstr ""
-#: ./src/pyams_content/component/links/interfaces/__init__.py:55
+#: ./src/pyams_content/component/links/interfaces/__init__.py:44
+msgid "Name of the pictogram associated with this link"
+msgstr ""
+
+#: ./src/pyams_content/component/links/interfaces/__init__.py:64
#: ./src/pyams_content/shared/logo/interfaces/__init__.py:50
msgid "Target URL"
msgstr ""
-#: ./src/pyams_content/component/links/interfaces/__init__.py:56
+#: ./src/pyams_content/component/links/interfaces/__init__.py:65
#: ./src/pyams_content/shared/logo/interfaces/__init__.py:51
msgid "URL used to access external resource"
msgstr ""
-#: ./src/pyams_content/component/links/interfaces/__init__.py:60
-msgid "Language used in this remote resource"
-msgstr ""
-
-#: ./src/pyams_content/component/links/interfaces/__init__.py:68
-msgid "Target address"
-msgstr ""
-
#: ./src/pyams_content/component/links/interfaces/__init__.py:69
+msgid "Language used in this remote resource"
+msgstr ""
+
+#: ./src/pyams_content/component/links/interfaces/__init__.py:77
+msgid "Target address"
+msgstr ""
+
+#: ./src/pyams_content/component/links/interfaces/__init__.py:78
msgid "Target email address"
msgstr ""
-#: ./src/pyams_content/component/links/interfaces/__init__.py:72
+#: ./src/pyams_content/component/links/interfaces/__init__.py:81
msgid "Address name"
msgstr ""
-#: ./src/pyams_content/component/links/interfaces/__init__.py:73
+#: ./src/pyams_content/component/links/interfaces/__init__.py:82
msgid "Address as displayed in address book"
msgstr ""
@@ -4243,6 +4243,11 @@
msgid "References"
msgstr ""
+#: ./src/pyams_content/reference/pictograms/zmi/__init__.py:172
+#: ./src/pyams_content/reference/pictograms/zmi/widget.py:55
+msgid "Default header: --"
+msgstr ""
+
#: ./src/pyams_content/reference/pictograms/zmi/manager.py:51
msgid "Pictograms selection..."
msgstr ""
--- a/src/pyams_content/reference/pictograms/manager.py Mon Jun 11 17:32:24 2018 +0200
+++ b/src/pyams_content/reference/pictograms/manager.py Tue Jun 12 10:50:18 2018 +0200
@@ -54,12 +54,16 @@
terms = []
table = query_utility(IPictogramTable)
if table is not None:
+ request = check_request()
target = get_parent(context, IPictogramManagerTarget)
if target is not None:
- request = check_request()
manager = IPictogramManager(target)
pictograms = [table.get(name) for name in manager.selected_pictograms]
terms = [SimpleTerm(v.__name__,
title=II18n(v).query_attribute('title', request=request))
for v in pictograms if v is not None]
+ else:
+ terms = [SimpleTerm(v.__name__,
+ title=II18n(v).query_attribute('title', request=request))
+ for v in table.values()]
super(SelectedPictogramsVocabulary, self).__init__(terms)
--- a/src/pyams_content/reference/pictograms/zmi/__init__.py Mon Jun 11 17:32:24 2018 +0200
+++ b/src/pyams_content/reference/pictograms/zmi/__init__.py Tue Jun 12 10:50:18 2018 +0200
@@ -43,7 +43,7 @@
from pyams_utils.url import absolute_url
from pyams_viewlet.viewlet import viewlet_config
from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
-from pyramid.httpexceptions import HTTPNotFound, HTTPBadRequest
+from pyramid.httpexceptions import HTTPNotFound
from pyramid.renderers import render, render_to_response
from pyramid.response import Response
from pyramid.view import view_config
@@ -166,11 +166,9 @@
permission=VIEW_SYSTEM_PERMISSION)
def get_pictogram_header_view(request):
"""View used to get thumbnail and alternate label associated with a given pictogram"""
+ translate = request.localizer.translate
name = request.params.get('value')
- if not name:
- raise HTTPBadRequest()
- translate = request.localizer.translate
- if name == '--NOVALUE--':
+ if (not name) or (name == '--NOVALUE--'):
return Response(translate(_("Default header: --")))
pictogram = request.context.get(name)
if pictogram is None:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/reference/pictograms/zmi/widget.py Tue Jun 12 10:50:18 2018 +0200
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2008-2018 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
+
+# import interfaces
+from pyams_content.reference.pictograms import IPictogramTable
+from pyams_utils.interfaces.data import IObjectData
+
+# import packages
+from pyams_content.reference.pictograms.zmi import get_pictogram_header
+from pyams_utils.registry import query_utility
+from pyams_utils.url import absolute_url
+from z3c.form.browser.select import SelectWidget
+from z3c.form.widget import FieldWidget
+from zope.interface import implementer
+
+from pyams_content import _
+
+
+@implementer(IObjectData)
+class PictogramSelectWidget(SelectWidget):
+ """Pictogram selection widget"""
+
+ pictograms = None
+ label_id = None
+ after_widget_notice = None
+
+ def update(self):
+ super(PictogramSelectWidget, self).update()
+ self.label_id = '{0}_header'.format(self.id)
+ self.pictograms = query_utility(IPictogramTable)
+ if self.value and (self.pictograms is not None):
+ pictogram = self.pictograms.get(self.value[0])
+ if pictogram is not None:
+ self.after_widget_notice = '<span id="{0}" class="text-info">{1}</span>'.format(
+ self.label_id,
+ get_pictogram_header(pictogram, self.request))
+ return
+ self.after_widget_notice = '<span id="{0}" class="text-info">{1}</span>'.format(
+ self.label_id,
+ self.request.localizer.translate(_("Default header: --")))
+
+ @property
+ def object_data(self):
+ return {
+ 'ams-change-handler': 'MyAMS.helpers.select2ChangeHelper',
+ 'ams-stop-propagation': 'true',
+ 'ams-select2-helper-type': 'html',
+ 'ams-select2-helper-url': absolute_url(self.pictograms, self.request, 'get-pictogram-header.html'),
+ 'ams-select2-helper-target': '#{0}'.format(self.label_id)
+ }
+
+
+def PictogramSelectFieldWidget(field, request):
+ return FieldWidget(field, PictogramSelectWidget(request))