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,187 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from collective.documentgenerator.events.styles_events import _update_template_styles
|
|
4
|
+
from collective.documentgenerator.events.styles_events import update_styles_of_all_PODtemplate
|
|
5
|
+
from collective.documentgenerator.testing import PODTemplateIntegrationTest
|
|
6
|
+
from plone import api
|
|
7
|
+
from plone.namedfile.file import NamedBlobFile
|
|
8
|
+
from zExceptions import Redirect
|
|
9
|
+
from zope.event import notify
|
|
10
|
+
from zope.interface import Interface
|
|
11
|
+
from zope.lifecycleevent import Attributes
|
|
12
|
+
from zope.lifecycleevent import ObjectModifiedEvent
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TestEvents(PODTemplateIntegrationTest):
|
|
18
|
+
"""
|
|
19
|
+
Test events methods.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def test_update_styles_of_all_PODtemplate(self):
|
|
23
|
+
# we use a ConfigurablePODTemplate to test style modification
|
|
24
|
+
style_template = self.portal.podtemplates.get("test_style_template")
|
|
25
|
+
# just call the function to pass on code
|
|
26
|
+
update_styles_of_all_PODtemplate(style_template, None)
|
|
27
|
+
|
|
28
|
+
def test__update_template_styles(self):
|
|
29
|
+
# style update is already tested in test_utils.py
|
|
30
|
+
# this is done to check error management
|
|
31
|
+
template = self.portal.podtemplates.get("test_template_multiple")
|
|
32
|
+
self.assertRaises(Redirect, _update_template_styles, template, None)
|
|
33
|
+
|
|
34
|
+
def _get_new_template_reusing_another(
|
|
35
|
+
self, id="test_template_reuse_temp", reuse_other=True
|
|
36
|
+
):
|
|
37
|
+
uid = None
|
|
38
|
+
if reuse_other:
|
|
39
|
+
uid = self.portal.podtemplates.get("test_template_reusable").UID()
|
|
40
|
+
|
|
41
|
+
portal = api.portal.get()
|
|
42
|
+
pod_folder = getattr(portal, "podtemplates")
|
|
43
|
+
api.content.create(
|
|
44
|
+
pod_template_to_use=uid,
|
|
45
|
+
type="ConfigurablePODTemplate",
|
|
46
|
+
id=id,
|
|
47
|
+
title=u"Temporary Reuse Test Template",
|
|
48
|
+
container=pod_folder,
|
|
49
|
+
exclude_from_nav=True,
|
|
50
|
+
pod_formats=["odt", "pdf", "doc", "docx"],
|
|
51
|
+
pod_portal_types=["Document"],
|
|
52
|
+
)
|
|
53
|
+
return getattr(pod_folder, id)
|
|
54
|
+
|
|
55
|
+
def test_crud_configurable_template_reusing_another(self):
|
|
56
|
+
reusable_template = self.portal.podtemplates.get("test_template_reusable")
|
|
57
|
+
template_reuse = self.portal.podtemplates.get("test_template_reuse")
|
|
58
|
+
self.assertSetEqual(
|
|
59
|
+
reusable_template.get_children_pod_template(), {template_reuse}
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
temp_template = self._get_new_template_reusing_another()
|
|
63
|
+
self.assertSetEqual(
|
|
64
|
+
reusable_template.get_children_pod_template(),
|
|
65
|
+
{temp_template, template_reuse},
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
temp_template.pod_template_to_use = None
|
|
69
|
+
self.assertSetEqual(
|
|
70
|
+
reusable_template.get_children_pod_template(), {template_reuse}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
temp_template.pod_template_to_use = reusable_template.UID()
|
|
74
|
+
self.assertSetEqual(
|
|
75
|
+
reusable_template.get_children_pod_template(),
|
|
76
|
+
{temp_template, template_reuse},
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
api.content.delete(temp_template)
|
|
80
|
+
self.assertEqual(
|
|
81
|
+
reusable_template.get_children_pod_template(), {template_reuse}
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
def test_clean_notes(self):
|
|
85
|
+
"""When PODTemplate created or modified, the "odt_file" note are cleaned."""
|
|
86
|
+
# original template_to_clean.odt holds dirty note
|
|
87
|
+
filename = u"template_to_clean.odt"
|
|
88
|
+
dirty_note = (
|
|
89
|
+
b"from xhtml(self.getMotivation() + </text:span>"
|
|
90
|
+
b'<text:span text:style-name="T1">self.getDecision())</text:span>'
|
|
91
|
+
)
|
|
92
|
+
cleaned_note = b"from xhtml(self.getMotivation() + self.getDecision())"
|
|
93
|
+
current_path = os.path.dirname(__file__)
|
|
94
|
+
dirty_data = open(os.path.join(current_path, filename), "rb").read()
|
|
95
|
+
dirty_content_xml = self.get_odt_content_xml(dirty_data)
|
|
96
|
+
self.assertTrue(dirty_note in dirty_content_xml)
|
|
97
|
+
self.assertFalse(cleaned_note in dirty_content_xml)
|
|
98
|
+
|
|
99
|
+
# create a new pod template it will be cleaned
|
|
100
|
+
pod_template = api.content.create(
|
|
101
|
+
type="ConfigurablePODTemplate",
|
|
102
|
+
id="template_to_clean",
|
|
103
|
+
title=u"Template to clean",
|
|
104
|
+
odt_file=NamedBlobFile(
|
|
105
|
+
data=dirty_data,
|
|
106
|
+
contentType="application/vnd.oasis.opendocument.text",
|
|
107
|
+
filename=filename,
|
|
108
|
+
),
|
|
109
|
+
pod_formats=["odt"],
|
|
110
|
+
container=self.portal.podtemplates,
|
|
111
|
+
)
|
|
112
|
+
cleaned_content_xml = self.get_odt_content_xml(pod_template.odt_file.data)
|
|
113
|
+
self.assertFalse(dirty_note in cleaned_content_xml)
|
|
114
|
+
self.assertTrue(cleaned_note in cleaned_content_xml)
|
|
115
|
+
# same behavior than style modification: template is considered unchanged
|
|
116
|
+
self.assertFalse(pod_template.has_been_modified())
|
|
117
|
+
|
|
118
|
+
# when updating file, new file is cleaned as well
|
|
119
|
+
pod_template.odt_file = NamedBlobFile(
|
|
120
|
+
data=dirty_data,
|
|
121
|
+
contentType="application/vnd.oasis.opendocument.text",
|
|
122
|
+
filename=filename,
|
|
123
|
+
)
|
|
124
|
+
self.assertTrue(
|
|
125
|
+
pod_template.has_been_modified()
|
|
126
|
+
) # template is manually changed
|
|
127
|
+
notify(ObjectModifiedEvent(pod_template, Attributes(Interface, "odt_file")))
|
|
128
|
+
cleaned_content_xml = self.get_odt_content_xml(pod_template.odt_file.data)
|
|
129
|
+
self.assertFalse(dirty_note in cleaned_content_xml)
|
|
130
|
+
self.assertTrue(cleaned_note in cleaned_content_xml)
|
|
131
|
+
|
|
132
|
+
def test_default_page_style_for_mailing(self):
|
|
133
|
+
"""When a mailing PODTemplate created or modified, set a default page style on it."""
|
|
134
|
+
filename = u"template_without_style_page.odt"
|
|
135
|
+
current_path = os.path.dirname(__file__)
|
|
136
|
+
odt_data = open(os.path.join(current_path, filename), "rb").read()
|
|
137
|
+
# activate the auto page style option
|
|
138
|
+
api.portal.set_registry_record(
|
|
139
|
+
"collective.documentgenerator.browser.controlpanel."
|
|
140
|
+
"IDocumentGeneratorControlPanelSchema.force_default_page_style_for_mailing",
|
|
141
|
+
True,
|
|
142
|
+
)
|
|
143
|
+
pod_template = api.content.create(
|
|
144
|
+
type="ConfigurablePODTemplate",
|
|
145
|
+
id="template_to_style",
|
|
146
|
+
title=u"Template to clean",
|
|
147
|
+
odt_file=NamedBlobFile(
|
|
148
|
+
data=odt_data,
|
|
149
|
+
contentType="application/vnd.oasis.opendocument.text",
|
|
150
|
+
filename=filename,
|
|
151
|
+
),
|
|
152
|
+
pod_formats=["odt"],
|
|
153
|
+
container=self.portal.podtemplates,
|
|
154
|
+
mailing_loop_template=1,
|
|
155
|
+
)
|
|
156
|
+
notify(ObjectModifiedEvent(pod_template))
|
|
157
|
+
# the page style should have been set -> odt contents are different
|
|
158
|
+
self.assertNotEqual(odt_data, pod_template.odt_file.data)
|
|
159
|
+
|
|
160
|
+
def test_default_page_style_for_mailing_disabled(self):
|
|
161
|
+
"""When a mailing PODTemplate created or modified, set a default page style on it
|
|
162
|
+
only if the setting 'force_default_page_style_for_mailing' is set to True."""
|
|
163
|
+
filename = u"template_without_style_page.odt"
|
|
164
|
+
current_path = os.path.dirname(__file__)
|
|
165
|
+
odt_data = open(os.path.join(current_path, filename), "rb").read()
|
|
166
|
+
# activate the auto page style option
|
|
167
|
+
api.portal.set_registry_record(
|
|
168
|
+
"collective.documentgenerator.browser.controlpanel."
|
|
169
|
+
"IDocumentGeneratorControlPanelSchema.force_default_page_style_for_mailing",
|
|
170
|
+
False,
|
|
171
|
+
)
|
|
172
|
+
pod_template = api.content.create(
|
|
173
|
+
type="ConfigurablePODTemplate",
|
|
174
|
+
id="template_to_style",
|
|
175
|
+
title=u"Template to clean",
|
|
176
|
+
odt_file=NamedBlobFile(
|
|
177
|
+
data=odt_data,
|
|
178
|
+
contentType="application/vnd.oasis.opendocument.text",
|
|
179
|
+
filename=filename,
|
|
180
|
+
),
|
|
181
|
+
pod_formats=["odt"],
|
|
182
|
+
container=self.portal.podtemplates,
|
|
183
|
+
mailing_loop_template=1,
|
|
184
|
+
)
|
|
185
|
+
notify(ObjectModifiedEvent(pod_template))
|
|
186
|
+
# no page style should have been set -> odt contents are still the same
|
|
187
|
+
self.assertEqual(odt_data, pod_template.odt_file.data)
|