Removed news publication properties edit form
authorThierry Florac <thierry.florac@onf.fr>
Wed, 12 Jul 2017 11:55:25 +0200
changeset 114 7799437055f1
parent 113 05caef75bac3
child 115 67a6a3b92612
Removed news publication properties edit form
src/pyams_content/shared/news/__init__.py
src/pyams_content/shared/news/interfaces/__init__.py
src/pyams_content/shared/news/zmi/properties.py
--- a/src/pyams_content/shared/news/__init__.py	Wed Jul 12 11:54:43 2017 +0200
+++ b/src/pyams_content/shared/news/__init__.py	Wed Jul 12 11:55:25 2017 +0200
@@ -21,48 +21,11 @@
 from pyams_content.component.links.interfaces import ILinkContainerTarget
 from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget
 from pyams_content.component.theme.interfaces import IThemesTarget
-from pyams_content.shared.news.interfaces import INewsEvent, IWfNewsEvent, NEWS_CONTENT_TYPE, NEWS_CONTENT_NAME, \
-    DISPLAY_FIRST_VERSION, DISPLAY_CURRENT_VERSION, VERSION_DISPLAY
-from pyams_workflow.interfaces import IWorkflowVersions, VersionError, IWorkflowPublicationInfo
+from pyams_content.shared.news.interfaces import INewsEvent, IWfNewsEvent, NEWS_CONTENT_TYPE, NEWS_CONTENT_NAME
 
 # import packages
 from pyams_content.shared.common import SharedContent, WfSharedContent, register_content_type
-from pyams_utils.date import format_date
-from pyams_utils.request import check_request
-from pyams_utils.vocabulary import vocabulary_config
 from zope.interface import implementer
-from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
-
-
-@vocabulary_config(name='PyAMS news publication date')
-class WfNewsDisplayedDateVocabulary(SimpleVocabulary):
-    """Base news event vocabulary"""
-
-    def __init__(self, context):
-        request = check_request()
-        terms = []
-        versions = IWorkflowVersions(context)
-        # check for current version
-        first_version_label = request.localizer.translate(VERSION_DISPLAY[DISPLAY_FIRST_VERSION])
-        try:
-            first_version = versions.get_version(1)
-        except VersionError:
-            pass
-        else:
-            info = IWorkflowPublicationInfo(first_version, None)
-            if info is not None and info.publication_effective_date:
-                first_version_label = '{0} ({1})'.format(first_version_label,
-                                                         format_date(info.publication_effective_date))
-        terms.append(SimpleTerm(DISPLAY_FIRST_VERSION, title=first_version_label))
-        # check for current version
-        current_version_label = request.localizer.translate(VERSION_DISPLAY[DISPLAY_CURRENT_VERSION])
-        info = IWorkflowPublicationInfo(context, None)
-        if info is not None and info.publication_effective_date:
-            current_version_label = '{0} ({1})'.format(current_version_label,
-                                                       format_date(info.publication_effective_date))
-        terms.append(SimpleTerm(DISPLAY_CURRENT_VERSION, title=current_version_label))
-        super(WfNewsDisplayedDateVocabulary, self).__init__(terms)
 
 
 @implementer(IWfNewsEvent, IParagraphContainerTarget, IThemesTarget, IExtFileContainerTarget, ILinkContainerTarget,
@@ -73,9 +36,6 @@
     content_type = NEWS_CONTENT_TYPE
     content_name = NEWS_CONTENT_NAME
 
-    displayed_publication_date = FieldProperty(IWfNewsEvent['displayed_publication_date'])
-    push_end_date = FieldProperty(IWfNewsEvent['push_end_date'])
-
 register_content_type(WfNewsEvent)
 
 
--- a/src/pyams_content/shared/news/interfaces/__init__.py	Wed Jul 12 11:54:43 2017 +0200
+++ b/src/pyams_content/shared/news/interfaces/__init__.py	Wed Jul 12 11:55:25 2017 +0200
@@ -19,9 +19,6 @@
 from pyams_content.shared.common.interfaces import ISharedTool, IWfSharedContent, ISharedContent
 
 # import packages
-from zope.interface import Attribute
-from zope.schema import Choice, Datetime
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from pyams_content import _
 
@@ -30,16 +27,6 @@
 NEWS_CONTENT_NAME = _("News topic")
 
 
-DISPLAY_FIRST_VERSION = 'first'
-DISPLAY_CURRENT_VERSION = 'current'
-
-VERSION_DISPLAY = {DISPLAY_FIRST_VERSION: _("Display first version date"),
-                   DISPLAY_CURRENT_VERSION: _("Display current version date")}
-
-VERSION_DISPLAY_VOCABULARY = SimpleVocabulary([SimpleTerm(v, title=t)
-                                               for v, t in VERSION_DISPLAY.items()])
-
-
 class INewsManager(ISharedTool):
     """News manager interface"""
 
@@ -47,20 +34,6 @@
 class IWfNewsEvent(IWfSharedContent):
     """News event interface"""
 
-    displayed_publication_date = Choice(title=_("Displayed publication date"),
-                                        description=_("The matching date will be displayed in front-office"),
-                                        vocabulary='PyAMS news publication date',
-                                        default=DISPLAY_FIRST_VERSION,
-                                        required=True)
-
-    publication_date = Attribute("Publication date")
-
-    push_end_date = Datetime(title=_("Push end date"),
-                             description=_("Some contents can be pushed by components to front-office pages; if you "
-                                           "set a date here, this content will not be pushed anymore passed this "
-                                           "date, but will still be available via the search engine"),
-                             required=False)
-
 
 class INewsEvent(ISharedContent):
     """Workflow managed news event interface"""
--- a/src/pyams_content/shared/news/zmi/properties.py	Wed Jul 12 11:54:43 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-#
-# 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
-
-# import interfaces
-from pyams_content.shared.news.interfaces import IWfNewsEvent
-from pyams_form.interfaces.form import IInnerSubForm
-from pyams_skin.layer import IPyAMSLayer
-
-# import packages
-from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm
-from pyams_utils.adapter import adapter_config
-from pyams_zmi.form import InnerAdminEditForm
-from z3c.form import field
-
-from pyams_content import _
-
-
-@adapter_config(name='publication',
-                context=(IWfNewsEvent, IPyAMSLayer, SharedContentPropertiesEditForm),
-                provides=IInnerSubForm)
-class NewsEventPropertiesEditForm(InnerAdminEditForm):
-    """News event properties edit form extension"""
-
-    legend = _("Publication settings")
-    fieldset_class = 'bordered no-x-margin margin-y-10'
-
-    fields = field.Fields(IWfNewsEvent).select('displayed_publication_date', 'push_end_date')