# HG changeset patch # User Thierry Florac # Date 1542356640 -3600 # Node ID a9a423fe6d02c1f8ed879d1a3e5956ed693b121a # Parent 6bccc6acea9d8b6c35b76211aee4f126ce3f00e0 Added internal reference to logos diff -r 6bccc6acea9d -r a9a423fe6d02 src/pyams_content/shared/logo/__init__.py --- a/src/pyams_content/shared/logo/__init__.py Fri Nov 16 08:55:51 2018 +0100 +++ b/src/pyams_content/shared/logo/__init__.py Fri Nov 16 09:24:00 2018 +0100 @@ -12,27 +12,24 @@ __docformat__ = 'restructuredtext' - -# import standard library - from zope.interface import implementer, provider from zope.schema.fieldproperty import FieldProperty -from pyams_content import _ -# import interfaces +from pyams_content.component.links import InternalReferenceMixin from pyams_content.component.theme.interfaces import IThemesTarget from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE from pyams_content.features.review.interfaces import IReviewTarget -# import packages -from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent, WfSharedContentChecker, \ - IWfSharedContentFactory -from pyams_content.shared.logo.interfaces import IWfLogo, LOGO_CONTENT_TYPE, LOGO_CONTENT_NAME, ILogo, IWfLogoFactory +from pyams_content.shared.common import IWfSharedContentFactory, SharedContent, WfSharedContent, WfSharedContentChecker, \ + register_content_type +from pyams_content.shared.logo.interfaces import ILogo, IWfLogo, IWfLogoFactory, LOGO_CONTENT_NAME, LOGO_CONTENT_TYPE from pyams_file.property import FileProperty from pyams_utils.adapter import adapter_config +from pyams_content import _ + @implementer(IWfLogo, IThemesTarget, IReviewTarget) -class WfLogo(WfSharedContent): +class WfLogo(WfSharedContent, InternalReferenceMixin): """Logo persistent class""" content_type = LOGO_CONTENT_TYPE @@ -44,9 +41,11 @@ acronym = FieldProperty(IWfLogo['acronym']) url = FieldProperty(IWfLogo['url']) + reference = FieldProperty(IWfLogo['reference']) image = FileProperty(IWfLogo['image']) monochrome_image = FileProperty(IWfLogo['monochrome_image']) + register_content_type(WfLogo) diff -r 6bccc6acea9d -r a9a423fe6d02 src/pyams_content/shared/logo/interfaces.py --- a/src/pyams_content/shared/logo/interfaces.py Fri Nov 16 08:55:51 2018 +0100 +++ b/src/pyams_content/shared/logo/interfaces.py Fri Nov 16 09:24:00 2018 +0100 @@ -12,21 +12,18 @@ __docformat__ = 'restructuredtext' - -# import standard library +from zope.interface import Interface +from zope.schema import Choice, TextLine, URI -from zope.interface import Interface -from zope.schema import URI, Choice, TextLine +from pyams_content.component.paragraph import IBaseParagraph +from pyams_content.shared.common.interfaces import ISharedContent, ISharedTool, IWfSharedContent +from pyams_file.schema import ImageField +from pyams_i18n.schema import I18nTextLineField +from pyams_sequence.interfaces import IInternalReference, IInternalReferencesList +from pyams_sequence.schema import InternalReferenceField, InternalReferencesListField from pyams_content import _ -# import interfaces -from pyams_content.component.paragraph import IBaseParagraph -from pyams_content.shared.common.interfaces import ISharedTool, IWfSharedContent, ISharedContent -# import packages -from pyams_file.schema import ImageField -from pyams_i18n.schema import I18nTextLineField -from pyams_sequence.interfaces import IInternalReferencesList -from pyams_sequence.schema import InternalReferencesListField + LOGO_CONTENT_TYPE = 'logo' LOGO_CONTENT_NAME = _("Logo") @@ -40,7 +37,7 @@ """Logos manager factory interface""" -class IWfLogo(IWfSharedContent): +class IWfLogo(IWfSharedContent, IInternalReference): """Logo interface""" title = I18nTextLineField(title=_("Title"), @@ -55,6 +52,12 @@ description=_("URL used to access external resource"), required=False) + reference = InternalReferenceField(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) + image = ImageField(title=_("Image (colored)"), description=_("Image data"), required=True) diff -r 6bccc6acea9d -r a9a423fe6d02 src/pyams_content/shared/logo/zmi/__init__.py --- a/src/pyams_content/shared/logo/zmi/__init__.py Fri Nov 16 08:55:51 2018 +0100 +++ b/src/pyams_content/shared/logo/zmi/__init__.py Fri Nov 16 09:24:00 2018 +0100 @@ -12,29 +12,24 @@ __docformat__ = 'restructuredtext' - -# import standard library +from pyramid.view import view_config +from zope.interface import Interface -# import interfaces from pyams_content.interfaces import CREATE_CONTENT_PERMISSION +from pyams_content.shared.common.zmi import SharedContentAJAXAddForm, SharedContentAddForm +from pyams_content.shared.logo import IWfLogo from pyams_content.shared.logo.interfaces import ILogosManager from pyams_i18n.interfaces import II18n +from pyams_pagelet.pagelet import pagelet_config from pyams_skin.interfaces import IContentTitle from pyams_skin.interfaces.viewlet import IMenuHeader, IWidgetTitleViewletManager from pyams_skin.layer import IPyAMSLayer +from pyams_skin.viewlet.toolbar import ToolbarAction +from pyams_utils.adapter import ContextRequestAdapter, ContextRequestViewAdapter, adapter_config +from pyams_viewlet.viewlet import viewlet_config from pyams_zmi.interfaces.menu import IContentManagementMenu from pyams_zmi.layer import IAdminLayer -# import packages -from pyams_content.shared.common.zmi import SharedContentAddForm, SharedContentAJAXAddForm -from pyams_content.shared.logo import IWfLogo -from pyams_pagelet.pagelet import pagelet_config -from pyams_skin.viewlet.toolbar import ToolbarAction -from pyams_utils.adapter import adapter_config, ContextRequestAdapter, ContextRequestViewAdapter -from pyams_viewlet.viewlet import viewlet_config -from pyramid.view import view_config -from zope.interface import Interface - from pyams_content import _ diff -r 6bccc6acea9d -r a9a423fe6d02 src/pyams_content/shared/logo/zmi/properties.py --- a/src/pyams_content/shared/logo/zmi/properties.py Fri Nov 16 08:55:51 2018 +0100 +++ b/src/pyams_content/shared/logo/zmi/properties.py Fri Nov 16 09:24:00 2018 +0100 @@ -9,27 +9,22 @@ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # -from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION -from pyams_form.form import ajax_config -from pyams_pagelet.pagelet import pagelet_config __docformat__ = 'restructuredtext' - -# import standard library +from z3c.form import field -# import interfaces +from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION +from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm +from pyams_content.shared.common.zmi.summary import SharedContentDublinCoreSummary, SharedContentSummaryForm from pyams_content.shared.logo import IWfLogo +from pyams_form.form import ajax_config from pyams_form.interfaces.form import IInnerSubForm, IInnerTabForm +from pyams_pagelet.pagelet import pagelet_config from pyams_sequence.interfaces import ISequentialIdInfo from pyams_skin.layer import IPyAMSLayer - -# import packages -from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm -from pyams_content.shared.common.zmi.summary import SharedContentSummaryForm, SharedContentDublinCoreSummary from pyams_utils.adapter import adapter_config from pyams_zmi.form import InnerAdminEditForm -from z3c.form import field from pyams_content import _ @@ -65,7 +60,7 @@ legend = _("Main logo settings") fieldset_class = 'bordered no-x-margin margin-y-10' - fields = field.Fields(IWfLogo).select('acronym', 'url', 'image', 'monochrome_image') + fields = field.Fields(IWfLogo).select('acronym', 'url', 'reference', 'image', 'monochrome_image') weight = 1 def get_ajax_output(self, changes):