Added based typed content properties edit form
authorThierry Florac <thierry.florac@onf.fr>
Thu, 27 Sep 2018 14:11:40 +0200
changeset 986 3fc7f8f84864
parent 985 5045e1a3a4bb
child 987 605fc8d4d54c
Added based typed content properties edit form
src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.mo
src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po
src/pyams_content/locales/pyams_content.pot
src/pyams_content/shared/common/zmi/types.py
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	Thu Sep 27 10:15:50 2018 +0200
+++ b/src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.po	Thu Sep 27 14:11:40 2018 +0200
@@ -5,7 +5,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2018-09-25 11:21+0200\n"
+"POT-Creation-Date: 2018-09-27 14:39+0200\n"
 "PO-Revision-Date: 2015-09-10 10:42+0200\n"
 "Last-Translator: Thierry Florac <tflorac@ulthar.net>\n"
 "Language-Team: French\n"
@@ -1004,21 +1004,21 @@
 msgid "Edit header paragraph properties"
 msgstr "Propriétés du chapô"
 
-#: src/pyams_content/component/paragraph/portlet/__init__.py:82
+#: src/pyams_content/component/paragraph/portlet/__init__.py:83
 msgid "Content paragraphs"
 msgstr "Blocs de contenu"
 
-#: src/pyams_content/component/paragraph/portlet/__init__.py:134
+#: src/pyams_content/component/paragraph/portlet/__init__.py:135
 msgid "Paragraphs navigation anchors"
 msgstr "Navigation au sein des blocs"
 
-#: src/pyams_content/component/paragraph/portlet/zmi/__init__.py:68
-#: src/pyams_content/component/paragraph/portlet/zmi/__init__.py:123
+#: src/pyams_content/component/paragraph/portlet/zmi/__init__.py:67
+#: src/pyams_content/component/paragraph/portlet/zmi/__init__.py:122
 msgid "No filter, all paragraphs selected"
 msgstr "Pas de filtre, tous les blocs sont acceptés"
 
-#: src/pyams_content/component/paragraph/portlet/zmi/__init__.py:75
-#: src/pyams_content/component/paragraph/portlet/zmi/__init__.py:130
+#: src/pyams_content/component/paragraph/portlet/zmi/__init__.py:74
+#: src/pyams_content/component/paragraph/portlet/zmi/__init__.py:129
 msgid "No filter, all paragraph types selected"
 msgstr "Pas de filtre, tous les types de blocs sont acceptés"
 
@@ -1189,8 +1189,8 @@
 msgstr "Liste des types de blocs de contenu autorisés pour ce gabarit."
 
 #: src/pyams_content/component/paragraph/interfaces/__init__.py:97
-#: src/pyams_content/shared/common/zmi/types.py:172
-#: src/pyams_content/shared/common/zmi/types.py:412
+#: src/pyams_content/shared/common/zmi/types.py:171
+#: src/pyams_content/shared/common/zmi/types.py:411
 msgid "Default paragraphs"
 msgstr "Types de blocs par défaut"
 
@@ -2095,79 +2095,84 @@
 msgid "Content properties"
 msgstr "Propriétés élémentaires"
 
-#: src/pyams_content/shared/common/zmi/types.py:70
+#: src/pyams_content/shared/common/zmi/types.py:69
 msgid "Data types"
 msgstr "Types de contenus"
 
-#: src/pyams_content/shared/common/zmi/types.py:148
+#: src/pyams_content/shared/common/zmi/types.py:147
 msgid "Data type label"
 msgstr "Libellé du type"
 
-#: src/pyams_content/shared/common/zmi/types.py:188
-#: src/pyams_content/shared/common/zmi/types.py:428
+#: src/pyams_content/shared/common/zmi/types.py:187
+#: src/pyams_content/shared/common/zmi/types.py:427
 msgid "Default associations"
 msgstr "Liens et pièces jointes par défaut"
 
-#: src/pyams_content/shared/common/zmi/types.py:204
+#: src/pyams_content/shared/common/zmi/types.py:203
 msgid "Default themes"
 msgstr "Thèmes par défaut"
 
-#: src/pyams_content/shared/common/zmi/types.py:232
+#: src/pyams_content/shared/common/zmi/types.py:231
 msgid "Content data types"
 msgstr "Types de contenus"
 
-#: src/pyams_content/shared/common/zmi/types.py:255
+#: src/pyams_content/shared/common/zmi/types.py:254
 msgid "Add data type"
 msgstr "Ajouter un type"
 
-#: src/pyams_content/shared/common/zmi/types.py:267
+#: src/pyams_content/shared/common/zmi/types.py:266
 msgid "Add new data type"
 msgstr "Ajout d'un type de contenu"
 
-#: src/pyams_content/shared/common/zmi/types.py:310
+#: src/pyams_content/shared/common/zmi/types.py:309
 msgid "Data type properties"
 msgstr "Propriétés du type de contenu"
 
-#: src/pyams_content/shared/common/zmi/types.py:391
+#: src/pyams_content/shared/common/zmi/types.py:390
 msgid "Subtype label"
 msgstr "Libellé du sous-type"
 
-#: src/pyams_content/shared/common/zmi/types.py:472
+#: src/pyams_content/shared/common/zmi/types.py:471
 msgid "Add subtype"
 msgstr "Ajouter un sous-type"
 
-#: src/pyams_content/shared/common/zmi/types.py:484
+#: src/pyams_content/shared/common/zmi/types.py:483
 msgid "Add new subtype"
 msgstr "Ajout d'un sous-type de contenu"
 
-#: src/pyams_content/shared/common/zmi/types.py:531
+#: src/pyams_content/shared/common/zmi/types.py:530
 msgid "Data subtype properties"
 msgstr "Propriétés du fichier standard"
 
-#: src/pyams_content/shared/common/zmi/types.py:573
+#: src/pyams_content/shared/common/zmi/types.py:572
 msgid "Select content type..."
 msgstr "Sélectionnez un type de contenu..."
 
-#: src/pyams_content/shared/common/zmi/types.py:115
+#: src/pyams_content/shared/common/zmi/types.py:114
 msgid "No currently defined data type."
 msgstr "Aucun type de contenu n'est actuellement défini."
 
-#: src/pyams_content/shared/common/zmi/types.py:300
+#: src/pyams_content/shared/common/zmi/types.py:299
 msgid "Specified type name is already used!"
 msgstr "Le nom indiqué pour ce type de contenu est déjà utilisé !"
 
-#: src/pyams_content/shared/common/zmi/types.py:507
+#: src/pyams_content/shared/common/zmi/types.py:506
 msgid "Subtype was correctly added."
 msgstr "Le sous-type a été ajouté."
 
-#: src/pyams_content/shared/common/zmi/types.py:521
+#: src/pyams_content/shared/common/zmi/types.py:520
 msgid "Specified subtype name is already used!"
 msgstr "Le nom indiqué pour ce sous-type de contenu est déjà utilisé !"
 
-#: src/pyams_content/shared/common/zmi/types.py:160
+#: src/pyams_content/shared/common/zmi/types.py:159
 msgid "Click to see subtypes"
 msgstr "Montrer ou caher les sous-types"
 
+#: src/pyams_content/shared/common/zmi/types.py:610
+#, python-format
+msgid "Custom properties for type « {0} »"
+msgstr "Propriétés spécifiques au type « {0} »"
+
 #: src/pyams_content/shared/common/zmi/workflow.py:847
 msgid "Prior checks"
 msgstr "Contrôles préalables : avez-vous ?"
@@ -3148,7 +3153,7 @@
 msgid "This content is already retired and not visible."
 msgstr "Ce contenu est déjà retiré et n'est plus visible des internautes."
 
-#: src/pyams_content/shared/common/portlet/title.py:39
+#: src/pyams_content/shared/common/portlet/title.py:38
 msgid "Content title"
 msgstr "Titre du gabarit"
 
@@ -3176,27 +3181,27 @@
 msgid "Display specificities"
 msgstr "Afficher les spécificités"
 
-#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:26
+#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:25
 msgid "Display breadcrumbs?"
 msgstr "Afficher le fil d'Ariane ?"
 
-#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:30
+#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:29
 msgid "Display title?"
 msgstr "Afficher le titre ?"
 
-#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:34
+#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:33
 msgid "Display tags?"
 msgstr "Afficher les tags ?"
 
-#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:38
+#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:37
 msgid "Display header?"
 msgstr "Afficher le chapô ?"
 
+#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:41
+msgid "Display specificities?"
+msgstr "Afficher les spécificités ?"
+
 #: src/pyams_content/shared/common/portlet/interfaces/__init__.py:42
-msgid "Display specificities?"
-msgstr "Afficher les spécificités ?"
-
-#: src/pyams_content/shared/common/portlet/interfaces/__init__.py:43
 msgid "If 'no', specific content's informations won't be displayed..."
 msgstr ""
 "Si 'non', les informations spécifiques que le gabarit est susceptible "
--- a/src/pyams_content/locales/pyams_content.pot	Thu Sep 27 10:15:50 2018 +0200
+++ b/src/pyams_content/locales/pyams_content.pot	Thu Sep 27 14:11:40 2018 +0200
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2018-09-25 11:21+0200\n"
+"POT-Creation-Date: 2018-09-27 14:39+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"
@@ -962,21 +962,21 @@
 msgid "Edit header paragraph properties"
 msgstr ""
 
-#: ./src/pyams_content/component/paragraph/portlet/__init__.py:82
+#: ./src/pyams_content/component/paragraph/portlet/__init__.py:83
 msgid "Content paragraphs"
 msgstr ""
 
-#: ./src/pyams_content/component/paragraph/portlet/__init__.py:134
+#: ./src/pyams_content/component/paragraph/portlet/__init__.py:135
 msgid "Paragraphs navigation anchors"
 msgstr ""
 
-#: ./src/pyams_content/component/paragraph/portlet/zmi/__init__.py:68
-#: ./src/pyams_content/component/paragraph/portlet/zmi/__init__.py:123
+#: ./src/pyams_content/component/paragraph/portlet/zmi/__init__.py:67
+#: ./src/pyams_content/component/paragraph/portlet/zmi/__init__.py:122
 msgid "No filter, all paragraphs selected"
 msgstr ""
 
-#: ./src/pyams_content/component/paragraph/portlet/zmi/__init__.py:75
-#: ./src/pyams_content/component/paragraph/portlet/zmi/__init__.py:130
+#: ./src/pyams_content/component/paragraph/portlet/zmi/__init__.py:74
+#: ./src/pyams_content/component/paragraph/portlet/zmi/__init__.py:129
 msgid "No filter, all paragraph types selected"
 msgstr ""
 
@@ -1125,8 +1125,8 @@
 msgstr ""
 
 #: ./src/pyams_content/component/paragraph/interfaces/__init__.py:97
-#: ./src/pyams_content/shared/common/zmi/types.py:172
-#: ./src/pyams_content/shared/common/zmi/types.py:412
+#: ./src/pyams_content/shared/common/zmi/types.py:171
+#: ./src/pyams_content/shared/common/zmi/types.py:411
 msgid "Default paragraphs"
 msgstr ""
 
@@ -1987,79 +1987,84 @@
 msgid "Content properties"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:70
+#: ./src/pyams_content/shared/common/zmi/types.py:69
 msgid "Data types"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:148
+#: ./src/pyams_content/shared/common/zmi/types.py:147
 msgid "Data type label"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:188
-#: ./src/pyams_content/shared/common/zmi/types.py:428
+#: ./src/pyams_content/shared/common/zmi/types.py:187
+#: ./src/pyams_content/shared/common/zmi/types.py:427
 msgid "Default associations"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:204
+#: ./src/pyams_content/shared/common/zmi/types.py:203
 msgid "Default themes"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:232
+#: ./src/pyams_content/shared/common/zmi/types.py:231
 msgid "Content data types"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:255
+#: ./src/pyams_content/shared/common/zmi/types.py:254
 msgid "Add data type"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:267
+#: ./src/pyams_content/shared/common/zmi/types.py:266
 msgid "Add new data type"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:310
+#: ./src/pyams_content/shared/common/zmi/types.py:309
 msgid "Data type properties"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:391
+#: ./src/pyams_content/shared/common/zmi/types.py:390
 msgid "Subtype label"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:472
+#: ./src/pyams_content/shared/common/zmi/types.py:471
 msgid "Add subtype"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:484
+#: ./src/pyams_content/shared/common/zmi/types.py:483
 msgid "Add new subtype"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:531
+#: ./src/pyams_content/shared/common/zmi/types.py:530
 msgid "Data subtype properties"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:573
+#: ./src/pyams_content/shared/common/zmi/types.py:572
 msgid "Select content type..."
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:115
+#: ./src/pyams_content/shared/common/zmi/types.py:114
 msgid "No currently defined data type."
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:300
+#: ./src/pyams_content/shared/common/zmi/types.py:299
 msgid "Specified type name is already used!"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:507
+#: ./src/pyams_content/shared/common/zmi/types.py:506
 msgid "Subtype was correctly added."
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:521
+#: ./src/pyams_content/shared/common/zmi/types.py:520
 msgid "Specified subtype name is already used!"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/zmi/types.py:160
+#: ./src/pyams_content/shared/common/zmi/types.py:159
 msgid "Click to see subtypes"
 msgstr ""
 
+#: ./src/pyams_content/shared/common/zmi/types.py:610
+#, python-format
+msgid "Custom properties for type « {0} »"
+msgstr ""
+
 #: ./src/pyams_content/shared/common/zmi/workflow.py:847
 msgid "Prior checks"
 msgstr ""
@@ -2965,7 +2970,7 @@
 msgid "This content is already retired and not visible."
 msgstr ""
 
-#: ./src/pyams_content/shared/common/portlet/title.py:39
+#: ./src/pyams_content/shared/common/portlet/title.py:38
 msgid "Content title"
 msgstr ""
 
@@ -2993,27 +2998,27 @@
 msgid "Display specificities"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:26
+#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:25
 msgid "Display breadcrumbs?"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:30
+#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:29
 msgid "Display title?"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:34
+#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:33
 msgid "Display tags?"
 msgstr ""
 
-#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:38
+#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:37
 msgid "Display header?"
 msgstr ""
 
+#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:41
+msgid "Display specificities?"
+msgstr ""
+
 #: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:42
-msgid "Display specificities?"
-msgstr ""
-
-#: ./src/pyams_content/shared/common/portlet/interfaces/__init__.py:43
 msgid "If 'no', specific content's informations won't be displayed..."
 msgstr ""
 
--- a/src/pyams_content/shared/common/zmi/types.py	Thu Sep 27 10:15:50 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/types.py	Thu Sep 27 14:11:40 2018 +0200
@@ -10,10 +10,9 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
+
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
 import json
 
 from pyramid.decorator import reify
@@ -23,12 +22,10 @@
 from z3c.form import field
 from z3c.form.interfaces import DISPLAY_MODE, IDataExtractedEvent
 from z3c.table.interfaces import IColumn, IValues
-from zope.interface import Invalid
+from zope.interface import Invalid, implementer
 
 from pyams_content import _
-# import interfaces
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION, MANAGE_TOOL_PERMISSION
-# import packages
 from pyams_content.reference.pictograms.zmi.widget import PictogramSelectFieldWidget
 from pyams_content.shared.common.interfaces.types import IBaseDataType, IDataType, ISubType, ITypedDataManager, \
     ITypedSharedTool, IWfTypedSharedContent
@@ -37,12 +34,14 @@
 from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm
 from pyams_content.skin import pyams_content
 from pyams_form.form import AJAXAddForm, ajax_config
+from pyams_form.interfaces.form import IWidgetForm
 from pyams_form.security import ProtectedFormObjectMixin
 from pyams_i18n.interfaces import II18n
 from pyams_i18n.widget import I18nSEOTextLineFieldWidget
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.container import delete_container_element
 from pyams_skin.event import get_json_table_refresh_event
+from pyams_skin.interfaces import IInnerPage
 from pyams_skin.interfaces.container import ITableElementName
 from pyams_skin.interfaces.viewlet import IWidgetTitleViewletManager
 from pyams_skin.layer import IPyAMSLayer
@@ -56,7 +55,7 @@
 from pyams_utils.url import absolute_url
 from pyams_viewlet.interfaces import IViewletManager
 from pyams_viewlet.viewlet import viewlet_config
-from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
+from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm, AdminEditForm
 from pyams_zmi.interfaces.menu import IPropertiesMenu
 from pyams_zmi.layer import IAdminLayer
 from pyams_zmi.view import ContainerAdminView
@@ -157,8 +156,8 @@
                '    </span>' \
                '</span>&nbsp;&nbsp;&nbsp;<span class="title">{title}</span>' \
                '<div class="inner-table-form subtypes margin-x-10 margin-bottom-0 padding-left-5"></div>'.format(
-                hint=self.request.localizer.translate(_("Click to see subtypes")),
-                title=super(TypedSharedToolTypesNameColumn, self).renderCell(item))
+            hint=self.request.localizer.translate(_("Click to see subtypes")),
+            title=super(TypedSharedToolTypesNameColumn, self).renderCell(item))
 
 
 @adapter_config(name='paragraphs', context=(ITypedSharedTool, IPyAMSLayer, TypedSharedToolTypesTable),
@@ -592,3 +591,28 @@
         if not self.context.handle_description:
             fields = fields.omit('description')
         return fields
+
+
+#
+# Typed shared content custom fields edit form
+#
+
+@implementer(IWidgetForm, IInnerPage)
+class TypedSharedContentTypeFieldsEditForm(AdminEditForm):
+    """Typed shared content type fields properties edit form"""
+
+    prefix = 'type_properties.'
+
+    @property
+    def legend(self):
+        translate = self.request.localizer.translate
+        data_type = self.context.get_data_type()
+        return translate(_("Custom properties for type « {0} »")).format(
+            II18n(data_type).query_attribute('label', request=self.request))
+
+    @property
+    def fields(self):
+        data_type = self.context.get_data_type()
+        if data_type is not None:
+            manager = get_parent(self.context, ITypedSharedTool)
+            return field.Fields(manager.shared_content_types_fields).select(*data_type.field_names)