Added illustration extension to thesaurus terms
authorThierry Florac <thierry.florac@onf.fr>
Tue, 10 Jul 2018 16:58:23 +0200
changeset 827 1eb993e1adfd
parent 826 eb16b1127e06
child 828 bf12603398b2
Added illustration extension to thesaurus terms
src/pyams_content/component/illustration/thesaurus.py
src/pyams_content/component/illustration/zmi/thesaurus.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/component/illustration/thesaurus.py	Tue Jul 10 16:58:23 2018 +0200
@@ -0,0 +1,37 @@
+#
+# 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.component.illustration import IBasicIllustrationTarget
+from pyams_thesaurus.interfaces.extension import IThesaurusTermExtension
+
+# import packages
+from pyams_utils.registry import utility_config
+
+from pyams_content import _
+
+
+@utility_config(name='illustration', provides=IThesaurusTermExtension)
+class IllustrationThesaurusExtension(object):
+    """Illustration thesaurus extension"""
+
+    label = _("Illustration")
+
+    target_interface = IBasicIllustrationTarget
+    target_view = 'illustration-dialog.html'
+
+    icon = '<i class="fa fa-fw fa-file-image-o"></i>'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/component/illustration/zmi/thesaurus.py	Tue Jul 10 16:58:23 2018 +0200
@@ -0,0 +1,50 @@
+#
+# 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.component.illustration.interfaces import IBasicIllustration, IIllustration
+from pyams_skin.layer import IPyAMSLayer
+from pyams_thesaurus.interfaces import MANAGE_THESAURUS_CONTENT_PERMISSION
+from pyams_thesaurus.interfaces.term import IThesaurusTerm
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+
+# import packages
+from pyams_form.form import ajax_config
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_zmi.form import AdminDialogEditForm
+from z3c.form import field
+
+from pyams_content import _
+
+
+@pagelet_config(name='illustration-dialog.html', context=IThesaurusTerm, layer=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
+@ajax_config(name='illustration-dialog.json', context=IThesaurusTerm, layer=IPyAMSLayer)
+class ThesaurusTermIllustrationPropertiesEditForm(AdminDialogEditForm):
+    """Thesaurus term illustration properties edit form"""
+
+    prefix = 'illustration_form.'
+
+    legend = _("Edit illustration properties")
+    dialog_class = 'modal-large'
+    icon_css_class = 'fa fa-fw fa-file-image-o'
+
+    fields = field.Fields(IBasicIllustration).omit('__parent__', '__name__')
+    edit_permission = MANAGE_THESAURUS_CONTENT_PERMISSION
+
+    def getContent(self):
+        return IIllustration(self.context)