collective.documentgenerator 4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- collective/documentgenerator/DX_renderer.py +51 -0
- collective/documentgenerator/__init__.py +11 -0
- collective/documentgenerator/adapters.py +30 -0
- collective/documentgenerator/browser/__init__.py +0 -0
- collective/documentgenerator/browser/actionspanel.py +19 -0
- collective/documentgenerator/browser/check_pod_templates.pt +86 -0
- collective/documentgenerator/browser/children_pod_template.pt +27 -0
- collective/documentgenerator/browser/configure.zcml +217 -0
- collective/documentgenerator/browser/controlpanel.py +165 -0
- collective/documentgenerator/browser/generation_view.py +613 -0
- collective/documentgenerator/browser/overrides.py +9 -0
- collective/documentgenerator/browser/resources/css/documentgenerator.css +133 -0
- collective/documentgenerator/browser/static/.gitkeep +0 -0
- collective/documentgenerator/browser/static/configurable.svg +1232 -0
- collective/documentgenerator/browser/static/csv.svg +521 -0
- collective/documentgenerator/browser/static/doc.svg +23 -0
- collective/documentgenerator/browser/static/docx.svg +20 -0
- collective/documentgenerator/browser/static/download_icon.svg +54 -0
- collective/documentgenerator/browser/static/libreoffice-blanck.svg +481 -0
- collective/documentgenerator/browser/static/mailinglooptemplate.svg +1207 -0
- collective/documentgenerator/browser/static/missing_use.svg +42 -0
- collective/documentgenerator/browser/static/nok.svg +38 -0
- collective/documentgenerator/browser/static/nok_use.svg +38 -0
- collective/documentgenerator/browser/static/nok_used.svg +38 -0
- collective/documentgenerator/browser/static/odp.svg +1264 -0
- collective/documentgenerator/browser/static/ods.svg +1354 -0
- collective/documentgenerator/browser/static/odt.svg +1347 -0
- collective/documentgenerator/browser/static/ok.svg +38 -0
- collective/documentgenerator/browser/static/ok_use.svg +38 -0
- collective/documentgenerator/browser/static/ok_used.svg +38 -0
- collective/documentgenerator/browser/static/pdf.svg +557 -0
- collective/documentgenerator/browser/static/podtemplate.svg +1197 -0
- collective/documentgenerator/browser/static/rtf.svg +521 -0
- collective/documentgenerator/browser/static/style.svg +1207 -0
- collective/documentgenerator/browser/static/subtemplate.svg +1232 -0
- collective/documentgenerator/browser/static/xls.svg +159 -0
- collective/documentgenerator/browser/static/xlsx.svg +48 -0
- collective/documentgenerator/browser/table.py +326 -0
- collective/documentgenerator/browser/templates_listing.pt +29 -0
- collective/documentgenerator/browser/views.py +366 -0
- collective/documentgenerator/config.py +174 -0
- collective/documentgenerator/configure.zcml +51 -0
- collective/documentgenerator/content/__init__.py +0 -0
- collective/documentgenerator/content/condition.py +66 -0
- collective/documentgenerator/content/conditions.zcml +30 -0
- collective/documentgenerator/content/configure.zcml +18 -0
- collective/documentgenerator/content/document_factory.py +73 -0
- collective/documentgenerator/content/file_representation.py +70 -0
- collective/documentgenerator/content/file_representation.zcml +29 -0
- collective/documentgenerator/content/merge_templates.py +15 -0
- collective/documentgenerator/content/merge_templates.zcml +11 -0
- collective/documentgenerator/content/pod_template.py +601 -0
- collective/documentgenerator/content/style_template.py +54 -0
- collective/documentgenerator/content/vocabulary.py +344 -0
- collective/documentgenerator/content/vocabulary.zcml +105 -0
- collective/documentgenerator/demo/__init__.py +0 -0
- collective/documentgenerator/demo/configure.zcml +18 -0
- collective/documentgenerator/demo/helper.py +170 -0
- collective/documentgenerator/events/__init__.py +0 -0
- collective/documentgenerator/events/configure.zcml +44 -0
- collective/documentgenerator/events/pod_templates_events.py +66 -0
- collective/documentgenerator/events/styles_events.py +151 -0
- collective/documentgenerator/helper/__init__.py +7 -0
- collective/documentgenerator/helper/base.py +334 -0
- collective/documentgenerator/helper/configure.zcml +34 -0
- collective/documentgenerator/helper/dexterity.py +178 -0
- collective/documentgenerator/interfaces.py +166 -0
- collective/documentgenerator/locales/collective.documentgenerator.pot +564 -0
- collective/documentgenerator/locales/es/LC_MESSAGES/collective.documentgenerator.po +572 -0
- collective/documentgenerator/locales/es/LC_MESSAGES/plone.po +32 -0
- collective/documentgenerator/locales/fr/LC_MESSAGES/collective.documentgenerator.po +566 -0
- collective/documentgenerator/locales/fr/LC_MESSAGES/plone.po +27 -0
- collective/documentgenerator/locales/manual.pot +30 -0
- collective/documentgenerator/locales/plone-manual.pot +22 -0
- collective/documentgenerator/locales/plone.pot +30 -0
- collective/documentgenerator/locales/update.sh +22 -0
- collective/documentgenerator/migrations/__init__.py +0 -0
- collective/documentgenerator/migrations/migrate_to_11.py +52 -0
- collective/documentgenerator/migrations/migrate_to_12.py +32 -0
- collective/documentgenerator/migrations/migrate_to_13.py +35 -0
- collective/documentgenerator/migrations/migrate_to_3.py +36 -0
- collective/documentgenerator/migrations/migrate_to_5.py +30 -0
- collective/documentgenerator/migrations/migrate_to_6.py +27 -0
- collective/documentgenerator/migrations/migrate_to_7.py +34 -0
- collective/documentgenerator/migrations/migrate_to_8.py +36 -0
- collective/documentgenerator/migrations/migrate_to_9.py +50 -0
- collective/documentgenerator/profiles/base/browserlayer.xml +6 -0
- collective/documentgenerator/profiles/base/controlpanel.xml +21 -0
- collective/documentgenerator/profiles/base/metadata.xml +8 -0
- collective/documentgenerator/profiles/base/registry.xml +48 -0
- collective/documentgenerator/profiles/base/types/ConfigurablePODTemplate.xml +69 -0
- collective/documentgenerator/profiles/base/types/MailingLoopTemplate.xml +68 -0
- collective/documentgenerator/profiles/base/types/PODTemplate.xml +68 -0
- collective/documentgenerator/profiles/base/types/StyleTemplate.xml +68 -0
- collective/documentgenerator/profiles/base/types/SubTemplate.xml +68 -0
- collective/documentgenerator/profiles/base/types.xml +22 -0
- collective/documentgenerator/profiles/base/viewlets.xml +10 -0
- collective/documentgenerator/profiles/demo/browserlayer.xml +6 -0
- collective/documentgenerator/profiles/demo/collectivedocumentgenerator_demo_marker.txt +0 -0
- collective/documentgenerator/profiles/demo/import_steps.xml +11 -0
- collective/documentgenerator/profiles/demo/metadata.xml +7 -0
- collective/documentgenerator/profiles/demo/registry.xml +14 -0
- collective/documentgenerator/profiles/demo/templates/mailing.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/modele_general.ods +0 -0
- collective/documentgenerator/profiles/demo/templates/modele_general.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/mod/303/250le_collection.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/possibly_mailed_model.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/styles.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/styles_2.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/sub_template.odt +0 -0
- collective/documentgenerator/profiles/demo/viewlets.xml +3 -0
- collective/documentgenerator/profiles/testing/metadata.xml +7 -0
- collective/documentgenerator/profiles/testing/types/member.xml +114 -0
- collective/documentgenerator/profiles/testing/types.xml +9 -0
- collective/documentgenerator/profiles/uninstall/browserlayer.xml +7 -0
- collective/documentgenerator/profiles/uninstall/controlpanel.xml +21 -0
- collective/documentgenerator/profiles/uninstall/metadata.xml +4 -0
- collective/documentgenerator/profiles/uninstall/registry.xml +14 -0
- collective/documentgenerator/profiles/uninstall/types.xml +27 -0
- collective/documentgenerator/profiles/uninstall/viewlets.xml +8 -0
- collective/documentgenerator/profiles.zcml +209 -0
- collective/documentgenerator/renderer.zcml +36 -0
- collective/documentgenerator/search_replace/__init__.py +0 -0
- collective/documentgenerator/search_replace/configure.zcml +21 -0
- collective/documentgenerator/search_replace/pod_template.py +161 -0
- collective/documentgenerator/search_replace/search_result_form.pt +76 -0
- collective/documentgenerator/search_replace/searchreplace_panel.pt +31 -0
- collective/documentgenerator/search_replace/searchreplace_panel.py +274 -0
- collective/documentgenerator/setuphandlers.py +297 -0
- collective/documentgenerator/testing.py +278 -0
- collective/documentgenerator/testing.zcml +17 -0
- collective/documentgenerator/tests/__init__.py +0 -0
- collective/documentgenerator/tests/failing_template.odt +0 -0
- collective/documentgenerator/tests/robot/.gitkeep +0 -0
- collective/documentgenerator/tests/template_to_clean.odt +0 -0
- collective/documentgenerator/tests/template_without_style_page.odt +0 -0
- collective/documentgenerator/tests/test_DX_helper_view.py +398 -0
- collective/documentgenerator/tests/test_base_helper_view.py +216 -0
- collective/documentgenerator/tests/test_check_podtemplates_view.py +138 -0
- collective/documentgenerator/tests/test_config.py +119 -0
- collective/documentgenerator/tests/test_configurable_pod_template.py +467 -0
- collective/documentgenerator/tests/test_demo_profile.py +121 -0
- collective/documentgenerator/tests/test_events.py +187 -0
- collective/documentgenerator/tests/test_generation_view.py +680 -0
- collective/documentgenerator/tests/test_mailing_loop_template.py +48 -0
- collective/documentgenerator/tests/test_pod_template.py +190 -0
- collective/documentgenerator/tests/test_robot.py +26 -0
- collective/documentgenerator/tests/test_search_replace.py +485 -0
- collective/documentgenerator/tests/test_setup.py +77 -0
- collective/documentgenerator/tests/test_style_template.py +19 -0
- collective/documentgenerator/tests/test_sub_template.py +49 -0
- collective/documentgenerator/tests/test_templates_listing_view.py +120 -0
- collective/documentgenerator/tests/test_utils.py +205 -0
- collective/documentgenerator/tests/test_vocabulary.py +169 -0
- collective/documentgenerator/utils.py +245 -0
- collective/documentgenerator/viewlets/__init__.py +0 -0
- collective/documentgenerator/viewlets/batchactions.py +14 -0
- collective/documentgenerator/viewlets/configure.zcml +17 -0
- collective/documentgenerator/viewlets/generationlinks.pt +46 -0
- collective/documentgenerator/viewlets/generationlinks.py +67 -0
- collective.documentgenerator-4.0-py3.12-nspkg.pth +1 -0
- collective_documentgenerator-4.0.dist-info/METADATA +1136 -0
- collective_documentgenerator-4.0.dist-info/RECORD +167 -0
- collective_documentgenerator-4.0.dist-info/WHEEL +5 -0
- collective_documentgenerator-4.0.dist-info/entry_points.txt +2 -0
- collective_documentgenerator-4.0.dist-info/namespace_packages.txt +1 -0
- collective_documentgenerator-4.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Adapters for dexterity fields rendering."""
|
|
3
|
+
|
|
4
|
+
from collective.documentgenerator.interfaces import IFieldRendererForDocument
|
|
5
|
+
from collective.excelexport.interfaces import IExportable
|
|
6
|
+
from zope.component import getMultiAdapter
|
|
7
|
+
from zope.interface import implementer
|
|
8
|
+
|
|
9
|
+
import datetime
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@implementer(IFieldRendererForDocument)
|
|
13
|
+
class DexterityExportableAdapter(object):
|
|
14
|
+
|
|
15
|
+
"""Adapter for collective.excelexport exportables."""
|
|
16
|
+
|
|
17
|
+
def __init__(self, field, context, request):
|
|
18
|
+
self.field = field
|
|
19
|
+
self.context = context
|
|
20
|
+
self.request = request
|
|
21
|
+
self.exportable = getMultiAdapter((field, context, request), IExportable)
|
|
22
|
+
|
|
23
|
+
def render_value(self):
|
|
24
|
+
"""Just delegate the rendering to the exportable."""
|
|
25
|
+
return self.exportable.render_value(self.context)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@implementer(IFieldRendererForDocument)
|
|
29
|
+
class DexterityDateExportableAdapter(DexterityExportableAdapter):
|
|
30
|
+
|
|
31
|
+
"""Adapter for collective.excelexport date field exportable."""
|
|
32
|
+
|
|
33
|
+
def render_value(self):
|
|
34
|
+
"""Format the date."""
|
|
35
|
+
value = self.exportable.render_value(self.context)
|
|
36
|
+
plone = getMultiAdapter((self.context, self.request), name=u"plone")
|
|
37
|
+
if isinstance(value, datetime.date):
|
|
38
|
+
value = datetime.datetime(value.year, value.month, value.day)
|
|
39
|
+
return plone.toLocalizedTime(value)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@implementer(IFieldRendererForDocument)
|
|
43
|
+
class DexterityDatetimeExportableAdapter(DexterityExportableAdapter):
|
|
44
|
+
|
|
45
|
+
"""Adapter for collective.excelexport datetime field exportable."""
|
|
46
|
+
|
|
47
|
+
def render_value(self):
|
|
48
|
+
"""Format the date."""
|
|
49
|
+
value = self.exportable.render_value(self.context)
|
|
50
|
+
plone = getMultiAdapter((self.context, self.request), name=u"plone")
|
|
51
|
+
return plone.toLocalizedTime(value, long_format=True)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from collective.documentgenerator.config import VIEWLET_TYPES
|
|
4
|
+
from plone import api
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class GenerablePODTemplatesAdapter(object):
|
|
8
|
+
""" """
|
|
9
|
+
|
|
10
|
+
def __init__(self, context):
|
|
11
|
+
self.context = context
|
|
12
|
+
|
|
13
|
+
def get_all_pod_templates(self):
|
|
14
|
+
catalog = api.portal.get_tool(name="portal_catalog")
|
|
15
|
+
brains = catalog.unrestrictedSearchResults(
|
|
16
|
+
portal_type=VIEWLET_TYPES, sort_on="getObjPositionInParent"
|
|
17
|
+
)
|
|
18
|
+
pod_templates = [
|
|
19
|
+
self.context.unrestrictedTraverse(brain.getPath()) for brain in brains
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
return pod_templates
|
|
23
|
+
|
|
24
|
+
def get_generable_templates(self):
|
|
25
|
+
pod_templates = self.get_all_pod_templates()
|
|
26
|
+
generable_templates = [
|
|
27
|
+
pt for pt in pod_templates if pt.can_be_generated(self.context)
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
return generable_templates
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from Products.CMFPlone.utils import base_hasattr
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from imio.actionspanel.browser.views import ActionsPanelView
|
|
7
|
+
|
|
8
|
+
class ConfigurablePODTemplateActionsPanelView(ActionsPanelView):
|
|
9
|
+
def mayExtEdit(self):
|
|
10
|
+
"""
|
|
11
|
+
Method that check if special 'external_edit' action has to be displayed.
|
|
12
|
+
"""
|
|
13
|
+
if base_hasattr(self.context, "pod_template_to_use"):
|
|
14
|
+
if getattr(self.context, "pod_template_to_use"):
|
|
15
|
+
return False
|
|
16
|
+
return super(ConfigurablePODTemplateActionsPanelView, self).mayExtEdit()
|
|
17
|
+
|
|
18
|
+
except ImportError:
|
|
19
|
+
pass
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
|
2
|
+
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
|
3
|
+
xmlns:metal="http://xml.zope.org/namespaces/metal"
|
|
4
|
+
xmlns:tal="http://xml.zope.org/namespaces/tal"
|
|
5
|
+
lang="en"
|
|
6
|
+
metal:use-macro="here/main_template/macros/master"
|
|
7
|
+
xml:lang="en"
|
|
8
|
+
i18n:domain="collective.documentgenerator"
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<metal:fill fill-slot="main">
|
|
13
|
+
|
|
14
|
+
<h1 class="documentFirstHeading"
|
|
15
|
+
i18n:translate="check_pod_templates"
|
|
16
|
+
>Check Pod templates</h1>
|
|
17
|
+
|
|
18
|
+
<tal:loop repeat="infos python: iter(view.messages.items())">
|
|
19
|
+
<h2 tal:define="
|
|
20
|
+
content python: infos[0];
|
|
21
|
+
"
|
|
22
|
+
tal:content="python: content"
|
|
23
|
+
tal:attributes="
|
|
24
|
+
class string:${content};
|
|
25
|
+
"
|
|
26
|
+
i18n:translate=""
|
|
27
|
+
></h2>
|
|
28
|
+
<tal:loop2 tal:condition="python: infos[1]"
|
|
29
|
+
repeat="path python: infos[1].keys()"
|
|
30
|
+
>
|
|
31
|
+
<h3 tal:content="python: path"></h3>
|
|
32
|
+
<tal:loop3 repeat="elt python: infos[1][path]">
|
|
33
|
+
<p><strong><span tal:content="python: elt[0].__class__.__name__">Pod Template</span>
|
|
34
|
+
:</strong>
|
|
35
|
+
<a href="#"
|
|
36
|
+
tal:content="python: elt[0].Title()"
|
|
37
|
+
tal:attributes="
|
|
38
|
+
href python: elt[0].absolute_url();
|
|
39
|
+
"
|
|
40
|
+
>
|
|
41
|
+
Link to template
|
|
42
|
+
</a>
|
|
43
|
+
<span i18n:translate="">Used object</span>
|
|
44
|
+
:
|
|
45
|
+
<a href="#"
|
|
46
|
+
tal:condition="python: elt[1]"
|
|
47
|
+
tal:content="python: elt[1].Title()"
|
|
48
|
+
tal:attributes="
|
|
49
|
+
href python: elt[1].absolute_url();
|
|
50
|
+
"
|
|
51
|
+
>
|
|
52
|
+
Link to used object
|
|
53
|
+
</a>
|
|
54
|
+
<span tal:condition="python: not elt[1]"
|
|
55
|
+
i18n:domain="plone"
|
|
56
|
+
i18n:translate="text_nomatches"
|
|
57
|
+
>
|
|
58
|
+
No object.
|
|
59
|
+
</span>
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
<tal:comment replace="nothing">Display additional message if any</tal:comment>
|
|
63
|
+
<tal:additioninfo condition="python: len(elt) == 3 and elt[2]">
|
|
64
|
+
<h4 style="display: inline;"><span tal:content="python: elt[2][0]">Additional info
|
|
65
|
+
type</span>
|
|
66
|
+
:</h4>
|
|
67
|
+
<p>
|
|
68
|
+
<pre tal:content="python: elt[2][1]">Additional info message</pre>
|
|
69
|
+
</p>
|
|
70
|
+
</tal:additioninfo>
|
|
71
|
+
<br />
|
|
72
|
+
</tal:loop3>
|
|
73
|
+
</tal:loop2>
|
|
74
|
+
<span class="discreet"
|
|
75
|
+
tal:condition="python: not infos[1]"
|
|
76
|
+
i18n:domain="plone"
|
|
77
|
+
i18n:translate="text_nomatches"
|
|
78
|
+
>
|
|
79
|
+
No results.
|
|
80
|
+
</span>
|
|
81
|
+
<p> </p>
|
|
82
|
+
</tal:loop>
|
|
83
|
+
|
|
84
|
+
</metal:fill>
|
|
85
|
+
</body>
|
|
86
|
+
</html>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<tal:defines define="
|
|
2
|
+
children view/get_children;
|
|
3
|
+
">
|
|
4
|
+
<label class="horizontal"
|
|
5
|
+
i18n:domain="collective.documentgenerator"
|
|
6
|
+
i18n:translate="Linked POD Template using this one"
|
|
7
|
+
></label>
|
|
8
|
+
<ul tal:condition="children">
|
|
9
|
+
<li tal:repeat="child children">
|
|
10
|
+
<a href="#"
|
|
11
|
+
tal:content="python: view.render_child(child)"
|
|
12
|
+
tal:attributes="
|
|
13
|
+
href child/absolute_url;
|
|
14
|
+
"
|
|
15
|
+
>
|
|
16
|
+
child title
|
|
17
|
+
</a>
|
|
18
|
+
</li>
|
|
19
|
+
</ul>
|
|
20
|
+
|
|
21
|
+
<p class="discreet"
|
|
22
|
+
tal:condition="not:children"
|
|
23
|
+
i18n:domain="collective.documentgenerator"
|
|
24
|
+
i18n:translate="None"
|
|
25
|
+
>None</p>
|
|
26
|
+
|
|
27
|
+
</tal:defines>
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
<configure
|
|
2
|
+
xmlns="http://namespaces.zope.org/zope"
|
|
3
|
+
xmlns:browser="http://namespaces.zope.org/browser"
|
|
4
|
+
xmlns:plone="http://namespaces.plone.org/plone"
|
|
5
|
+
xmlns:zcml="http://namespaces.zope.org/zcml"
|
|
6
|
+
i18n_domain="collective.documentgenerator"
|
|
7
|
+
>
|
|
8
|
+
|
|
9
|
+
<!-- Publish static files -->
|
|
10
|
+
<browser:resourceDirectory
|
|
11
|
+
name="collective.documentgenerator"
|
|
12
|
+
directory="static"
|
|
13
|
+
/>
|
|
14
|
+
|
|
15
|
+
<browser:resourceDirectory
|
|
16
|
+
name="collective.documentgenerator.css"
|
|
17
|
+
directory="resources/css"
|
|
18
|
+
layer="..interfaces.ICollectiveDocumentGeneratorLayer"
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
<!-- views -->
|
|
22
|
+
<browser:page
|
|
23
|
+
name="document-generation"
|
|
24
|
+
for="*"
|
|
25
|
+
class="collective.documentgenerator.browser.generation_view.DocumentGenerationView"
|
|
26
|
+
permission="zope2.View"
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
<browser:page
|
|
30
|
+
name="persistent-document-generation"
|
|
31
|
+
for="*"
|
|
32
|
+
class="collective.documentgenerator.browser.generation_view.PersistentDocumentGenerationView"
|
|
33
|
+
permission="zope2.View"
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
<browser:page
|
|
37
|
+
name="mailing-loop-persistent-document-generation"
|
|
38
|
+
for="*"
|
|
39
|
+
class="collective.documentgenerator.browser.generation_view.MailingLoopPersistentDocumentGenerationView"
|
|
40
|
+
permission="zope2.View"
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
<browser:page
|
|
44
|
+
name="collective.documentgenerator-controlpanel"
|
|
45
|
+
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
|
|
46
|
+
class="collective.documentgenerator.browser.controlpanel.DocumentGeneratorSettings"
|
|
47
|
+
permission="cmf.ManagePortal"
|
|
48
|
+
layer="..interfaces.ICollectiveDocumentGeneratorLayer"
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
<browser:page
|
|
52
|
+
name="dg-reset-md5"
|
|
53
|
+
for="collective.documentgenerator.content.pod_template.IPODTemplate"
|
|
54
|
+
class=".views.ResetMd5"
|
|
55
|
+
permission="cmf.ModifyPortalContent"
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
<configure package="plone.app.dexterity.browser">
|
|
59
|
+
<browser:page
|
|
60
|
+
name="view"
|
|
61
|
+
for="collective.documentgenerator.content.pod_template.IConfigurablePODTemplate"
|
|
62
|
+
class="collective.documentgenerator.browser.views.ViewConfigurablePodTemplate"
|
|
63
|
+
template="item.pt"
|
|
64
|
+
permission="zope2.View"
|
|
65
|
+
/>
|
|
66
|
+
</configure>
|
|
67
|
+
|
|
68
|
+
<browser:page
|
|
69
|
+
name="edit"
|
|
70
|
+
for="collective.documentgenerator.content.pod_template.IConfigurablePODTemplate"
|
|
71
|
+
class=".views.EditConfigurablePodTemplate"
|
|
72
|
+
permission="cmf.ModifyPortalContent"
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
<browser:page
|
|
76
|
+
name="dg-templates-listing"
|
|
77
|
+
for="*"
|
|
78
|
+
class=".views.TemplatesListing"
|
|
79
|
+
template="templates_listing.pt"
|
|
80
|
+
permission="zope2.View"
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
<!-- configure actionspanel -->
|
|
84
|
+
<configure
|
|
85
|
+
package="imio.actionspanel"
|
|
86
|
+
zcml:condition="installed imio.actionspanel"
|
|
87
|
+
>
|
|
88
|
+
|
|
89
|
+
<browser:page
|
|
90
|
+
name="actions_panel"
|
|
91
|
+
for="collective.documentgenerator.content.pod_template.IConfigurablePODTemplate"
|
|
92
|
+
class="collective.documentgenerator.browser.actionspanel.ConfigurablePODTemplateActionsPanelView"
|
|
93
|
+
template="browser/actions_panel.pt"
|
|
94
|
+
permission="zope2.View"
|
|
95
|
+
layer="imio.actionspanel.interfaces.IActionsPanelLayer"
|
|
96
|
+
/>
|
|
97
|
+
|
|
98
|
+
</configure>
|
|
99
|
+
|
|
100
|
+
<!-- z3c.table -->
|
|
101
|
+
<adapter
|
|
102
|
+
factory=".table.CheckBoxColumn"
|
|
103
|
+
provides="z3c.table.interfaces.IColumn"
|
|
104
|
+
for="zope.interface.Interface
|
|
105
|
+
zope.publisher.interfaces.browser.IBrowserRequest
|
|
106
|
+
.table.TemplatesTable"
|
|
107
|
+
name="select_row"
|
|
108
|
+
zcml:condition="installed collective.eeafaceted.batchactions"
|
|
109
|
+
/>
|
|
110
|
+
|
|
111
|
+
<adapter
|
|
112
|
+
factory=".table.TitleColumn"
|
|
113
|
+
provides="z3c.table.interfaces.IColumn"
|
|
114
|
+
for="zope.interface.Interface
|
|
115
|
+
zope.interface.Interface
|
|
116
|
+
.table.TemplatesTable"
|
|
117
|
+
name="TitleColumn"
|
|
118
|
+
/>
|
|
119
|
+
|
|
120
|
+
<adapter
|
|
121
|
+
factory=".table.PathColumn"
|
|
122
|
+
provides="z3c.table.interfaces.IColumn"
|
|
123
|
+
for="zope.interface.Interface
|
|
124
|
+
zope.interface.Interface
|
|
125
|
+
.table.TemplatesTable"
|
|
126
|
+
name="PathColumn"
|
|
127
|
+
/>
|
|
128
|
+
|
|
129
|
+
<adapter
|
|
130
|
+
factory=".table.EnabledColumn"
|
|
131
|
+
provides="z3c.table.interfaces.IColumn"
|
|
132
|
+
for="zope.interface.Interface
|
|
133
|
+
zope.interface.Interface
|
|
134
|
+
.table.TemplatesTable"
|
|
135
|
+
name="EnabledColumn"
|
|
136
|
+
/>
|
|
137
|
+
|
|
138
|
+
<adapter
|
|
139
|
+
factory=".table.OriginalColumn"
|
|
140
|
+
provides="z3c.table.interfaces.IColumn"
|
|
141
|
+
for="zope.interface.Interface
|
|
142
|
+
zope.interface.Interface
|
|
143
|
+
.table.TemplatesTable"
|
|
144
|
+
name="OriginalColumn"
|
|
145
|
+
/>
|
|
146
|
+
|
|
147
|
+
<adapter
|
|
148
|
+
factory=".table.FormatsColumn"
|
|
149
|
+
provides="z3c.table.interfaces.IColumn"
|
|
150
|
+
for="zope.interface.Interface
|
|
151
|
+
zope.interface.Interface
|
|
152
|
+
.table.TemplatesTable"
|
|
153
|
+
name="FormatsColumn"
|
|
154
|
+
/>
|
|
155
|
+
|
|
156
|
+
<adapter
|
|
157
|
+
factory=".table.ReviewStateColumn"
|
|
158
|
+
provides="z3c.table.interfaces.IColumn"
|
|
159
|
+
for="zope.interface.Interface
|
|
160
|
+
zope.interface.Interface
|
|
161
|
+
.table.TemplatesTable"
|
|
162
|
+
name="ReviewStateColumn"
|
|
163
|
+
/>
|
|
164
|
+
|
|
165
|
+
<adapter
|
|
166
|
+
factory=".table.ActionsColumn"
|
|
167
|
+
provides="z3c.table.interfaces.IColumn"
|
|
168
|
+
for="zope.interface.Interface
|
|
169
|
+
zope.interface.Interface
|
|
170
|
+
.table.TemplatesTable"
|
|
171
|
+
name="ActionsColumn"
|
|
172
|
+
zcml:condition="installed imio.actionspanel"
|
|
173
|
+
/>
|
|
174
|
+
|
|
175
|
+
<adapter
|
|
176
|
+
factory=".table.DownloadColumn"
|
|
177
|
+
provides="z3c.table.interfaces.IColumn"
|
|
178
|
+
for="zope.interface.Interface
|
|
179
|
+
zope.interface.Interface
|
|
180
|
+
.table.TemplatesTable"
|
|
181
|
+
name="DownloadColumn"
|
|
182
|
+
/>
|
|
183
|
+
|
|
184
|
+
<!-- batchactions -->
|
|
185
|
+
<browser:viewlet
|
|
186
|
+
name="collective.eeafaceted.batchactions"
|
|
187
|
+
for="collective.documentgenerator.interfaces.IBelowContentBodyBatchActionsMarker"
|
|
188
|
+
manager="plone.app.layout.viewlets.interfaces.IBelowContentBody"
|
|
189
|
+
class="collective.documentgenerator.viewlets.batchactions.DGBatchActionsViewlet"
|
|
190
|
+
permission="zope2.View"
|
|
191
|
+
zcml:condition="installed collective.eeafaceted.batchactions"
|
|
192
|
+
/>
|
|
193
|
+
|
|
194
|
+
<!-- Override the documentviewer for IConfigurablePODTemplate so it uses ViewConfigurablePodTemplate too -->
|
|
195
|
+
<configure
|
|
196
|
+
package="collective.documentviewer.browser"
|
|
197
|
+
zcml:condition="installed collective.documentviewer"
|
|
198
|
+
>
|
|
199
|
+
<browser:page
|
|
200
|
+
name="documentviewer"
|
|
201
|
+
for="collective.documentgenerator.content.pod_template.IConfigurablePODTemplate"
|
|
202
|
+
class="collective.documentgenerator.browser.overrides.DGDXDocumentViewerView"
|
|
203
|
+
template="templates/documentviewer.pt"
|
|
204
|
+
permission="zope2.View"
|
|
205
|
+
layer="..interfaces.ILayer"
|
|
206
|
+
/>
|
|
207
|
+
</configure>
|
|
208
|
+
|
|
209
|
+
<browser:page
|
|
210
|
+
name="check-pod-templates"
|
|
211
|
+
for="*"
|
|
212
|
+
class=".views.CheckPodTemplatesView"
|
|
213
|
+
template="check_pod_templates.pt"
|
|
214
|
+
permission="cmf.ManagePortal"
|
|
215
|
+
/>
|
|
216
|
+
|
|
217
|
+
</configure>
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from collective.documentgenerator import _
|
|
4
|
+
from collective.documentgenerator import interfaces
|
|
5
|
+
from collective.documentgenerator.config import DEFAULT_COLUMN_MODIFIER
|
|
6
|
+
from collective.documentgenerator.config import DEFAULT_OO_PORT
|
|
7
|
+
from collective.documentgenerator.config import DEFAULT_OO_SERVER
|
|
8
|
+
from collective.documentgenerator.config import DEFAULT_PYTHON_UNO
|
|
9
|
+
from collective.documentgenerator.interfaces import IDocumentGeneratorSettings
|
|
10
|
+
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
|
|
11
|
+
from plone.app.registry.browser.controlpanel import RegistryEditForm
|
|
12
|
+
from Products.CMFPlone.utils import safe_unicode
|
|
13
|
+
from Products.statusmessages.interfaces import IStatusMessage
|
|
14
|
+
from z3c.form import button
|
|
15
|
+
from zope import schema
|
|
16
|
+
from zope.interface import implementer
|
|
17
|
+
from zope.interface import Interface
|
|
18
|
+
|
|
19
|
+
import inspect
|
|
20
|
+
import os
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
COLUMN_MODIFIER_DESCR = _(
|
|
24
|
+
u'If enabled, this will allow the "table-layout: fixed|auto|none" '
|
|
25
|
+
u"CSS style handling while generating document. If no such style is defined on the table, "
|
|
26
|
+
u"the chosen column modifier of LibreOffice will be applied."
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _string_to_boolean(value):
|
|
31
|
+
return value == "True"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def check_for_uno(value):
|
|
35
|
+
""" """
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
inspect.isabstract(IDocumentGeneratorControlPanelSchema)
|
|
39
|
+
except Exception:
|
|
40
|
+
return True
|
|
41
|
+
if "python" not in value and os.system(value + " -V") != 0:
|
|
42
|
+
raise interfaces.InvalidPythonPath()
|
|
43
|
+
if os.system(value + ' -c "import unohelper"') != 0:
|
|
44
|
+
raise interfaces.InvalidUnoPath()
|
|
45
|
+
return True
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class IDocumentGeneratorControlPanelSchema(Interface):
|
|
49
|
+
""" """
|
|
50
|
+
|
|
51
|
+
oo_server = schema.TextLine(
|
|
52
|
+
title=_(u"oo_server"),
|
|
53
|
+
description=_(u"IP address or hostname of OO."),
|
|
54
|
+
required=False,
|
|
55
|
+
default=safe_unicode(os.getenv("OO_SERVER", DEFAULT_OO_SERVER)),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
oo_port_list = schema.TextLine(
|
|
59
|
+
title=_(u"oo_port_list"),
|
|
60
|
+
description=_(u"Port Number(s) of OO."),
|
|
61
|
+
required=False,
|
|
62
|
+
default=safe_unicode(os.getenv("OO_PORT", DEFAULT_OO_PORT)),
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
uno_path = schema.TextLine(
|
|
66
|
+
title=_(u"uno path"),
|
|
67
|
+
description=_(u"Path of python with uno."),
|
|
68
|
+
required=False,
|
|
69
|
+
default=safe_unicode(os.getenv("PYTHON_UNO", DEFAULT_PYTHON_UNO)),
|
|
70
|
+
constraint=check_for_uno,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
column_modifier = schema.Choice(
|
|
74
|
+
title=_(u"Table column modifier"),
|
|
75
|
+
description=_(COLUMN_MODIFIER_DESCR),
|
|
76
|
+
vocabulary="collective.documentgenerator.ConfigColumnModifier",
|
|
77
|
+
required=True,
|
|
78
|
+
default=DEFAULT_COLUMN_MODIFIER,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
raiseOnError_for_non_managers = schema.Bool(
|
|
82
|
+
title=_(u"Raise an error instead generating the document"),
|
|
83
|
+
description=_(
|
|
84
|
+
u"If enabled, this will avoid generating a document "
|
|
85
|
+
u"containing an error, instead a common Plone error will "
|
|
86
|
+
u"be raised. Nevertheless to ease debugging, Managers "
|
|
87
|
+
u"will continue to get errors in the generated document "
|
|
88
|
+
u"if it uses .odt format."
|
|
89
|
+
),
|
|
90
|
+
required=False,
|
|
91
|
+
default=False,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
use_stream = schema.Choice(
|
|
95
|
+
title=_(u"Force communication via in/out stream with LibreOffice."),
|
|
96
|
+
description=_(
|
|
97
|
+
u"If enabled, this will force using stream to communicate witth LibreOffice server. "
|
|
98
|
+
u"This must be true if the LO server is not on localhost or is in a docker container."
|
|
99
|
+
),
|
|
100
|
+
required=True,
|
|
101
|
+
vocabulary="collective.documentgenerator.ConfigStream",
|
|
102
|
+
default=os.getenv("USE_STREAM", None) is None
|
|
103
|
+
and "auto"
|
|
104
|
+
or _string_to_boolean(os.getenv("USE_STREAM")),
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
force_default_page_style_for_mailing = schema.Bool(
|
|
108
|
+
title=_(u"Apply a default page style on mailing POD templates"),
|
|
109
|
+
description=_(
|
|
110
|
+
u"If enabled, this will automatically apply the default page style on the firstparagraph"
|
|
111
|
+
u'of a POD template using the "mailing" attribute (if no page style was set).'
|
|
112
|
+
),
|
|
113
|
+
required=False,
|
|
114
|
+
default=False,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@implementer(IDocumentGeneratorSettings)
|
|
119
|
+
class DocumentGeneratorControlPanelEditForm(RegistryEditForm):
|
|
120
|
+
schema = IDocumentGeneratorControlPanelSchema
|
|
121
|
+
label = _(u"Document Generator settings")
|
|
122
|
+
description = _(u"The Document Generator settings control panel")
|
|
123
|
+
|
|
124
|
+
@button.buttonAndHandler(_("Save"), name=None)
|
|
125
|
+
def handle_save(self, action):
|
|
126
|
+
data, errors = self.extractData()
|
|
127
|
+
if errors:
|
|
128
|
+
self.status = self.formErrorsMessage
|
|
129
|
+
return
|
|
130
|
+
|
|
131
|
+
self.applyChanges(data)
|
|
132
|
+
IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"), "info")
|
|
133
|
+
self.context.REQUEST.RESPONSE.redirect(
|
|
134
|
+
"@@collective.documentgenerator-controlpanel"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
@button.buttonAndHandler(_("Search & replace"), name="search_and_replace")
|
|
138
|
+
def handleSearchAndReplace(self, action):
|
|
139
|
+
self.request.response.redirect(
|
|
140
|
+
"{context_url}/{view}".format(
|
|
141
|
+
context_url=self.context.absolute_url(),
|
|
142
|
+
view="@@collective.documentgenerator-searchreplacepanel",
|
|
143
|
+
)
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
@button.buttonAndHandler(_("Check Pod Templates"), name="checkPod")
|
|
147
|
+
def handleCheckPod(self, action):
|
|
148
|
+
self.request.response.redirect(
|
|
149
|
+
"{context_url}/{view}".format(
|
|
150
|
+
context_url=self.context.absolute_url(), view="@@check-pod-templates"
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
@button.buttonAndHandler(_("Cancel"), name="cancel")
|
|
155
|
+
def handleCancel(self, action):
|
|
156
|
+
IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"), "info")
|
|
157
|
+
self.request.response.redirect(
|
|
158
|
+
"{context_url}/{view}".format(
|
|
159
|
+
context_url=self.context.absolute_url(), view="@@overview-controlpanel"
|
|
160
|
+
)
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class DocumentGeneratorSettings(ControlPanelFormWrapper):
|
|
165
|
+
form = DocumentGeneratorControlPanelEditForm
|