imio.annex 2.26__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.
- imio/annex/__init__.py +10 -0
- imio/annex/adapters.py +52 -0
- imio/annex/behaviors.py +12 -0
- imio/annex/browser/__init__.py +0 -0
- imio/annex/browser/configure.zcml +26 -0
- imio/annex/browser/static/view_element.png +0 -0
- imio/annex/browser/views.py +301 -0
- imio/annex/columns.py +101 -0
- imio/annex/configure.zcml +65 -0
- imio/annex/content/__init__.py +0 -0
- imio/annex/content/annex.py +85 -0
- imio/annex/content/configure.zcml +43 -0
- imio/annex/content/events.py +49 -0
- imio/annex/events.py +33 -0
- imio/annex/interfaces.py +27 -0
- imio/annex/locales/collective.eeafaceted.batchactions.pot +46 -0
- imio/annex/locales/collective.quickupload.pot +10 -0
- imio/annex/locales/fr/LC_MESSAGES/collective.eeafaceted.batchactions.po +43 -0
- imio/annex/locales/fr/LC_MESSAGES/collective.quickupload.po +19 -0
- imio/annex/locales/fr/LC_MESSAGES/imio.annex.po +67 -0
- imio/annex/locales/fr/LC_MESSAGES/plone.po +21 -0
- imio/annex/locales/imio.annex.pot +70 -0
- imio/annex/locales/plone.pot +24 -0
- imio/annex/locales/update.sh +30 -0
- imio/annex/overrides.zcml +96 -0
- imio/annex/patch.py +29 -0
- imio/annex/profiles/default/browserlayer.xml +7 -0
- imio/annex/profiles/default/cssregistry.xml +18 -0
- imio/annex/profiles/default/imioannex_default.txt +0 -0
- imio/annex/profiles/default/jsregistry.xml +7 -0
- imio/annex/profiles/default/metadata.xml +10 -0
- imio/annex/profiles/default/propertiestool.xml +8 -0
- imio/annex/profiles/default/types/annex.xml +58 -0
- imio/annex/profiles/default/types.xml +5 -0
- imio/annex/profiles/default/workflows.xml +9 -0
- imio/annex/profiles.zcml +44 -0
- imio/annex/quickupload/__init__.py +0 -0
- imio/annex/quickupload/configure.zcml +19 -0
- imio/annex/quickupload/form.py +73 -0
- imio/annex/quickupload/quickupload.py +369 -0
- imio/annex/quickupload/static/helpers.js +57 -0
- imio/annex/quickupload/static/quickupload.css +45 -0
- imio/annex/quickupload/templates/form.pt +5 -0
- imio/annex/quickupload/templates/quick_upload.pt +67 -0
- imio/annex/quickupload/utils.py +23 -0
- imio/annex/safe_utils.py +4 -0
- imio/annex/setuphandlers.py +7 -0
- imio/annex/utils.py +75 -0
- imio.annex-2.26-py3.12-nspkg.pth +1 -0
- imio_annex-2.26.dist-info/METADATA +441 -0
- imio_annex-2.26.dist-info/RECORD +55 -0
- imio_annex-2.26.dist-info/WHEEL +5 -0
- imio_annex-2.26.dist-info/entry_points.txt +2 -0
- imio_annex-2.26.dist-info/namespace_packages.txt +1 -0
- imio_annex-2.26.dist-info/top_level.txt +1 -0
imio/annex/__init__.py
ADDED
imio/annex/adapters.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from collective.iconifiedcategory.utils import get_category_icon_url
|
|
4
|
+
from collective.iconifiedcategory.utils import get_category_object
|
|
5
|
+
from imio.prettylink.adapters import PrettyLinkAdapter
|
|
6
|
+
from zope.i18n import translate
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AnnexPrettyLinkAdapter(PrettyLinkAdapter):
|
|
10
|
+
"""
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def _get_url(self):
|
|
14
|
+
""" """
|
|
15
|
+
if self.is_preview:
|
|
16
|
+
url = self.context.absolute_url()
|
|
17
|
+
return u"{0}/documentviewer#document/#/p1".format(url)
|
|
18
|
+
else:
|
|
19
|
+
return super(AnnexPrettyLinkAdapter, self)._get_url()
|
|
20
|
+
|
|
21
|
+
def _leadingIcons(self):
|
|
22
|
+
"""
|
|
23
|
+
Manage icons to display before the annex title.
|
|
24
|
+
"""
|
|
25
|
+
res = []
|
|
26
|
+
parent = self.context.aq_parent
|
|
27
|
+
element = parent.categorized_elements[self.context.UID()]
|
|
28
|
+
self.infos = parent.unrestrictedTraverse('@@categorized-childs-infos')
|
|
29
|
+
|
|
30
|
+
# preview in progress
|
|
31
|
+
if element["preview_status"] == 'in_progress':
|
|
32
|
+
res.append(
|
|
33
|
+
('spinner_small.gif',
|
|
34
|
+
translate("The document is currently under conversion, "
|
|
35
|
+
"please refresh the page in a few minutes",
|
|
36
|
+
domain="collective.iconifiedcategory",
|
|
37
|
+
context=self.request)))
|
|
38
|
+
# category icon
|
|
39
|
+
category = get_category_object(self.context, self.context.content_category)
|
|
40
|
+
category_url = get_category_icon_url(category)
|
|
41
|
+
res.append((category_url,
|
|
42
|
+
category.title))
|
|
43
|
+
|
|
44
|
+
# is a preview, store is_preview as it is reused in _get_url
|
|
45
|
+
self.is_preview = self.infos.show_preview(element)
|
|
46
|
+
if self.is_preview:
|
|
47
|
+
res.append(('file_icon.png',
|
|
48
|
+
translate(
|
|
49
|
+
"Preview",
|
|
50
|
+
domain="collective.iconifiedcategory",
|
|
51
|
+
context=self.request)))
|
|
52
|
+
return res
|
imio/annex/behaviors.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from collective.dms.scanbehavior.behaviors.behaviors import IScanFields
|
|
4
|
+
from plone.autoform.interfaces import IFormFieldProvider
|
|
5
|
+
from zope.interface import alsoProvides
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class IScanFieldsHiddenToSignAndSigned(IScanFields):
|
|
9
|
+
"""Must be removed once there is no more usage of this behavior"""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
alsoProvides(IScanFieldsHiddenToSignAndSigned, IFormFieldProvider)
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
i18n_domain="imio.annex">
|
|
6
|
+
|
|
7
|
+
<!-- Publish static files -->
|
|
8
|
+
<browser:resourceDirectory
|
|
9
|
+
name="imio.annex"
|
|
10
|
+
directory="static" />
|
|
11
|
+
|
|
12
|
+
<!-- Download annexes as Zip batch action -->
|
|
13
|
+
<!--browser:page
|
|
14
|
+
for="collective.eeafaceted.batchactions.interfaces.IBatchActionsMarker"
|
|
15
|
+
name="download-annexes-batch-action"
|
|
16
|
+
class="imio.annex.browser.views.DownloadAnnexesBatchActionForm"
|
|
17
|
+
permission="zope2.View" /-->
|
|
18
|
+
|
|
19
|
+
<!-- Concatenate annexes batch action -->
|
|
20
|
+
<!--browser:page
|
|
21
|
+
for="collective.eeafaceted.batchactions.interfaces.IBatchActionsMarker"
|
|
22
|
+
name="concatenate-annexes-batch-action"
|
|
23
|
+
class="imio.annex.browser.views.ConcatenateAnnexesBatchActionForm"
|
|
24
|
+
permission="zope2.View" /-->
|
|
25
|
+
|
|
26
|
+
</configure>
|
|
Binary file
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from collective.eeafaceted.batchactions import _ as _CEBA
|
|
4
|
+
from collective.eeafaceted.batchactions.browser.views import BaseBatchActionForm
|
|
5
|
+
from collective.iconifiedcategory.config import get_sort_categorized_tab
|
|
6
|
+
from collective.iconifiedcategory.utils import calculate_filesize
|
|
7
|
+
from collective.iconifiedcategory.utils import get_categorized_elements
|
|
8
|
+
from imio.annex import _
|
|
9
|
+
from imio.annex import logger
|
|
10
|
+
from imio.annex.content.annex import IAnnex
|
|
11
|
+
from io import BytesIO
|
|
12
|
+
from plone import api
|
|
13
|
+
from plone.rfc822.interfaces import IPrimaryFieldInfo
|
|
14
|
+
from Products.CMFPlone.utils import safe_unicode
|
|
15
|
+
from Products.PloneMeeting.widgets.pm_checkbox import PMCheckBoxFieldWidget
|
|
16
|
+
from PyPDF2 import PdfFileReader
|
|
17
|
+
from PyPDF2 import PdfFileWriter
|
|
18
|
+
from PyPDF2.utils import PdfReadError
|
|
19
|
+
from z3c.form.browser.radio import RadioFieldWidget
|
|
20
|
+
from z3c.form.field import Fields
|
|
21
|
+
from zope import schema
|
|
22
|
+
from zope.i18n import translate
|
|
23
|
+
|
|
24
|
+
import zipfile
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class DownloadAnnexesBatchActionForm(BaseBatchActionForm):
|
|
28
|
+
|
|
29
|
+
label = _CEBA("download-annexes-batch-action-but")
|
|
30
|
+
button_with_icon = True
|
|
31
|
+
apply_button_title = _CEBA('Download')
|
|
32
|
+
section = "annexes"
|
|
33
|
+
# gives a human readable size of "50.0 Mb"
|
|
34
|
+
MAX_TOTAL_SIZE = 52428800
|
|
35
|
+
|
|
36
|
+
def _max_total_size(self):
|
|
37
|
+
""" """
|
|
38
|
+
return self.MAX_TOTAL_SIZE
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def description(self):
|
|
42
|
+
""" """
|
|
43
|
+
descr = super(DownloadAnnexesBatchActionForm, self).description
|
|
44
|
+
descr = translate(descr, domain=descr.domain, context=self.request)
|
|
45
|
+
if self.total_size > self._max_total_size():
|
|
46
|
+
readable_max_size = calculate_filesize(self._max_total_size())
|
|
47
|
+
descr += translate(
|
|
48
|
+
'<p class="warn_filesize">The maximum size you may download at '
|
|
49
|
+
'one time is ${max_size}, here your download size is ${total_size}. '
|
|
50
|
+
'Please unselect some elements, especially large elements for '
|
|
51
|
+
'which size is displayed in red, download it separately.<p>',
|
|
52
|
+
mapping={'max_size': readable_max_size,
|
|
53
|
+
'total_size': calculate_filesize(self.total_size)},
|
|
54
|
+
domain="collective.eeafaceted.batchactions",
|
|
55
|
+
context=self.request)
|
|
56
|
+
elif self.annex_not_downloadable is not None:
|
|
57
|
+
descr += translate(
|
|
58
|
+
'<p style="color: red;">You selected some elements that are '
|
|
59
|
+
'not downloadable, check for example "${annex_title}". '
|
|
60
|
+
'Please unselect elements that are only previewable.</p>',
|
|
61
|
+
mapping={'annex_title': self.annex_not_downloadable.Title()},
|
|
62
|
+
domain="collective.eeafaceted.batchactions",
|
|
63
|
+
context=self.request)
|
|
64
|
+
else:
|
|
65
|
+
descr += translate(
|
|
66
|
+
'<p>This will download the selected elements as a Zip file.</p>'
|
|
67
|
+
'<p>The total file size is <b>${total_size}</b>, when clicking '
|
|
68
|
+
'on "${button_title}", you will have a spinner, wait until the '
|
|
69
|
+
'Zip file is available.</p>',
|
|
70
|
+
mapping={
|
|
71
|
+
'total_size': calculate_filesize(self.total_size),
|
|
72
|
+
'button_title': translate(
|
|
73
|
+
self.apply_button_title,
|
|
74
|
+
domain="collective.eeafaceted.batchactions",
|
|
75
|
+
context=self.request)},
|
|
76
|
+
domain="collective.eeafaceted.batchactions",
|
|
77
|
+
context=self.request)
|
|
78
|
+
return descr
|
|
79
|
+
|
|
80
|
+
def _check_annex_not_downloadable(self):
|
|
81
|
+
""" """
|
|
82
|
+
self.annex_not_downloadable = None
|
|
83
|
+
for brain in self.brains:
|
|
84
|
+
obj = brain.getObject()
|
|
85
|
+
if not obj.show_download():
|
|
86
|
+
self.annex_not_downloadable = obj
|
|
87
|
+
self.do_apply = False
|
|
88
|
+
return
|
|
89
|
+
|
|
90
|
+
def _check_total_size(self):
|
|
91
|
+
""" """
|
|
92
|
+
self.total_size = self._total_size()
|
|
93
|
+
if self.total_size > self._max_total_size():
|
|
94
|
+
self.do_apply = False
|
|
95
|
+
|
|
96
|
+
def _total_size(self):
|
|
97
|
+
""" """
|
|
98
|
+
total = 0
|
|
99
|
+
for brain in self.brains:
|
|
100
|
+
obj = brain.getObject()
|
|
101
|
+
primary_field = IPrimaryFieldInfo(obj)
|
|
102
|
+
size = primary_field.value.size
|
|
103
|
+
total += size
|
|
104
|
+
return total
|
|
105
|
+
|
|
106
|
+
def _update(self):
|
|
107
|
+
"""Can not apply action if total size exceeded."""
|
|
108
|
+
self._check_total_size()
|
|
109
|
+
if self.do_apply:
|
|
110
|
+
self._check_annex_not_downloadable()
|
|
111
|
+
|
|
112
|
+
def available(self):
|
|
113
|
+
""" """
|
|
114
|
+
return True
|
|
115
|
+
|
|
116
|
+
def zipfiles(self, content):
|
|
117
|
+
"""Return zipped content."""
|
|
118
|
+
fstream = BytesIO()
|
|
119
|
+
zipper = zipfile.ZipFile(fstream, 'w', zipfile.ZIP_DEFLATED)
|
|
120
|
+
for obj in content:
|
|
121
|
+
if not IAnnex.providedBy(obj):
|
|
122
|
+
continue
|
|
123
|
+
primary_field = IPrimaryFieldInfo(obj)
|
|
124
|
+
data = primary_field.value.data
|
|
125
|
+
filename = primary_field.value.filename
|
|
126
|
+
# can not do without a filename...
|
|
127
|
+
if not filename:
|
|
128
|
+
continue
|
|
129
|
+
zipper.writestr(filename, data)
|
|
130
|
+
created = obj.created()
|
|
131
|
+
zipper.NameToInfo[filename].date_time = (
|
|
132
|
+
created.year(),
|
|
133
|
+
created.month(),
|
|
134
|
+
created.day(),
|
|
135
|
+
created.hour(),
|
|
136
|
+
created.minute(),
|
|
137
|
+
int(created.second()))
|
|
138
|
+
zipper.close()
|
|
139
|
+
return fstream.getvalue()
|
|
140
|
+
|
|
141
|
+
def _apply(self, **data):
|
|
142
|
+
""" """
|
|
143
|
+
try:
|
|
144
|
+
return self.do_zip()
|
|
145
|
+
except zipfile.LargeZipFile:
|
|
146
|
+
message = "Too much annexes to zip, try selecting fewer annexes..."
|
|
147
|
+
api.portal.show_message(message, self.request, type="error")
|
|
148
|
+
return self.request.response.redirect(self.context.absolute_url())
|
|
149
|
+
|
|
150
|
+
def do_zip(self):
|
|
151
|
+
""" Zip all of the content in this location (context)"""
|
|
152
|
+
self.request.response.setHeader('Content-Type', 'application/zip')
|
|
153
|
+
self.request.response.setHeader(
|
|
154
|
+
'Content-disposition', 'attachment;filename=%s.zip'
|
|
155
|
+
% self.context.getId())
|
|
156
|
+
content = [brain.getObject() for brain in self.brains]
|
|
157
|
+
zipped_content = self.zipfiles(content)
|
|
158
|
+
self.request.set('zip_file_content', zipped_content)
|
|
159
|
+
return zipped_content
|
|
160
|
+
|
|
161
|
+
def render(self):
|
|
162
|
+
""" """
|
|
163
|
+
if 'zip_file_content' in self.request:
|
|
164
|
+
return self.request['zip_file_content']
|
|
165
|
+
else:
|
|
166
|
+
return super(DownloadAnnexesBatchActionForm, self).render()
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class ConcatenateAnnexesBatchActionForm(BaseBatchActionForm):
|
|
170
|
+
|
|
171
|
+
label = _CEBA("concatenate-annexes-batch-action-but")
|
|
172
|
+
button_with_icon = True
|
|
173
|
+
apply_button_title = _CEBA('Download')
|
|
174
|
+
# gives a human readable size of "75.0 Mb"
|
|
175
|
+
MAX_TOTAL_SIZE = 78643200
|
|
176
|
+
|
|
177
|
+
def _max_total_size(self):
|
|
178
|
+
""" """
|
|
179
|
+
return self.MAX_TOTAL_SIZE
|
|
180
|
+
|
|
181
|
+
@property
|
|
182
|
+
def description(self):
|
|
183
|
+
""" """
|
|
184
|
+
descr = super(ConcatenateAnnexesBatchActionForm, self).description
|
|
185
|
+
descr = translate(descr, domain=descr.domain, context=self.request)
|
|
186
|
+
readable_max_size = calculate_filesize(self._max_total_size())
|
|
187
|
+
descr += translate(
|
|
188
|
+
'concatenate_annexes_batch_action_descr',
|
|
189
|
+
mapping={'max_size': readable_max_size, },
|
|
190
|
+
domain="collective.eeafaceted.batchactions",
|
|
191
|
+
context=self.request)
|
|
192
|
+
return descr
|
|
193
|
+
|
|
194
|
+
def _annex_types_vocabulary(self):
|
|
195
|
+
"""The name of the vocabulary factory to use for annex_types field."""
|
|
196
|
+
return "collective.iconifiedcategory.every_category_uids"
|
|
197
|
+
|
|
198
|
+
def _update(self):
|
|
199
|
+
self.fields += Fields(
|
|
200
|
+
schema.List(
|
|
201
|
+
__name__='annex_types',
|
|
202
|
+
title=_(u'Annex types'),
|
|
203
|
+
value_type=schema.Choice(
|
|
204
|
+
vocabulary=self._annex_types_vocabulary()),
|
|
205
|
+
required=True),
|
|
206
|
+
schema.Bool(__name__='two_sided',
|
|
207
|
+
title=_(u'Two-sided?'),
|
|
208
|
+
description=_(u'descr_two_sided'),
|
|
209
|
+
default=False,
|
|
210
|
+
required=False),
|
|
211
|
+
)
|
|
212
|
+
self.fields["annex_types"].widgetFactory = PMCheckBoxFieldWidget
|
|
213
|
+
self.fields["two_sided"].widgetFactory = RadioFieldWidget
|
|
214
|
+
|
|
215
|
+
def _total_size(self, annexes):
|
|
216
|
+
""" """
|
|
217
|
+
total = 0
|
|
218
|
+
for annex in annexes:
|
|
219
|
+
primary_field = IPrimaryFieldInfo(annex)
|
|
220
|
+
size = primary_field.value.size
|
|
221
|
+
total += size
|
|
222
|
+
return total
|
|
223
|
+
|
|
224
|
+
def _error_obj_title(self, obj):
|
|
225
|
+
""" """
|
|
226
|
+
return obj.Title()
|
|
227
|
+
|
|
228
|
+
def _apply(self, **data):
|
|
229
|
+
""" """
|
|
230
|
+
annex_type_uids = data['annex_types']
|
|
231
|
+
# get annexes
|
|
232
|
+
annexes = []
|
|
233
|
+
sort_on = 'getObjPositionInParent' if \
|
|
234
|
+
get_sort_categorized_tab() is False else None
|
|
235
|
+
for brain in self.brains:
|
|
236
|
+
obj = brain.getObject()
|
|
237
|
+
filters = {'contentType': 'application/pdf'}
|
|
238
|
+
for annex_type_uid in annex_type_uids:
|
|
239
|
+
filters['category_uid'] = annex_type_uid
|
|
240
|
+
annexes += get_categorized_elements(
|
|
241
|
+
obj,
|
|
242
|
+
result_type='objects',
|
|
243
|
+
sort_on=sort_on,
|
|
244
|
+
filters=filters)
|
|
245
|
+
# return if nothing to produce
|
|
246
|
+
if not annexes:
|
|
247
|
+
api.portal.show_message(
|
|
248
|
+
_("Nothing to export."),
|
|
249
|
+
request=self.request)
|
|
250
|
+
return
|
|
251
|
+
# can not generate if total size too large
|
|
252
|
+
total_size = self._total_size(annexes)
|
|
253
|
+
if self._total_size(annexes) > self._max_total_size():
|
|
254
|
+
api.portal.show_message(
|
|
255
|
+
_("concatenate_annexes_pdf_too_large_error",
|
|
256
|
+
mapping={'total_size': calculate_filesize(total_size),
|
|
257
|
+
'max_total_size': calculate_filesize(
|
|
258
|
+
self._max_total_size())}),
|
|
259
|
+
request=self.request,
|
|
260
|
+
type="error")
|
|
261
|
+
return
|
|
262
|
+
# create unique PDF file
|
|
263
|
+
output_writer = PdfFileWriter()
|
|
264
|
+
for annex in annexes:
|
|
265
|
+
try:
|
|
266
|
+
output_writer.appendPagesFromReader(
|
|
267
|
+
PdfFileReader(BytesIO(annex.file.data), strict=False))
|
|
268
|
+
except PdfReadError as exc:
|
|
269
|
+
api.portal.show_message(
|
|
270
|
+
_("concatenate_annexes_pdf_read_error",
|
|
271
|
+
mapping={'annex_title': safe_unicode(annex.Title()),
|
|
272
|
+
'obj_title': safe_unicode(
|
|
273
|
+
self._error_obj_title(annex.aq_inner.aq_parent))}),
|
|
274
|
+
request=self.request,
|
|
275
|
+
type="error")
|
|
276
|
+
logger.exception(exc)
|
|
277
|
+
self.request.set(
|
|
278
|
+
'concatenate_annexes_item_pdf_error_url', obj.absolute_url())
|
|
279
|
+
return
|
|
280
|
+
if data['two_sided'] and \
|
|
281
|
+
output_writer.getNumPages() % 2 != 0 and \
|
|
282
|
+
annex != annexes[-1]:
|
|
283
|
+
output_writer.addBlankPage()
|
|
284
|
+
pdf_file_content = BytesIO()
|
|
285
|
+
output_writer.write(pdf_file_content)
|
|
286
|
+
self.request.set('pdf_file_content', pdf_file_content)
|
|
287
|
+
return pdf_file_content
|
|
288
|
+
|
|
289
|
+
def render(self):
|
|
290
|
+
if 'pdf_file_content' in self.request:
|
|
291
|
+
filename = "%s-annexes.pdf" % self.context.getId()
|
|
292
|
+
self.request.response.setHeader('Content-Type', 'application/pdf')
|
|
293
|
+
self.request.response.setHeader(
|
|
294
|
+
'Content-disposition', 'attachment; filename=%s' % filename)
|
|
295
|
+
pdf_file_content = self.request['pdf_file_content']
|
|
296
|
+
pdf_file_content.seek(0)
|
|
297
|
+
return pdf_file_content.read()
|
|
298
|
+
elif self.request.RESPONSE.status == 204:
|
|
299
|
+
# return something so the faceted is refrehsed
|
|
300
|
+
return self.request.get('concatenate_annexes_pdf_error_url')
|
|
301
|
+
return super(ConcatenateAnnexesBatchActionForm, self).render()
|
imio/annex/columns.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from collective.eeafaceted.z3ctable.columns import ActionsColumn as DashboardActionsColumn
|
|
4
|
+
from collective.eeafaceted.z3ctable.columns import BaseColumn
|
|
5
|
+
from collective.eeafaceted.z3ctable.columns import DateColumn
|
|
6
|
+
from collective.eeafaceted.z3ctable.columns import MemberIdColumn
|
|
7
|
+
from collective.eeafaceted.z3ctable.columns import PrettyLinkColumn as DashboardPrettyLinkColumn
|
|
8
|
+
from collective.iconifiedcategory.browser.tabview import AuthorColumn as IconifiedAuthorColumn
|
|
9
|
+
from collective.iconifiedcategory.browser.tabview import CategoryColumn as IconifiedCategoryColumn
|
|
10
|
+
from collective.iconifiedcategory.browser.tabview import CreationDateColumn as IconifiedCreationDateColumn
|
|
11
|
+
from collective.iconifiedcategory.browser.tabview import FilesizeColumn as IconifiedFilesizeColumn
|
|
12
|
+
from collective.iconifiedcategory.browser.tabview import LastModificationColumn as IconifiedLastModificationColumn
|
|
13
|
+
from collective.iconifiedcategory.interfaces import IIconifiedCategorySettings
|
|
14
|
+
from imio.annex import _
|
|
15
|
+
from plone import api
|
|
16
|
+
from Products.CMFPlone.utils import safe_unicode
|
|
17
|
+
from zope.i18n import translate
|
|
18
|
+
|
|
19
|
+
import html
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PrettyLinkColumn(DashboardPrettyLinkColumn):
|
|
23
|
+
header = _(u'Title')
|
|
24
|
+
weight = 20
|
|
25
|
+
|
|
26
|
+
# link to a file, open in new tab
|
|
27
|
+
params = {'target': '_blank'}
|
|
28
|
+
|
|
29
|
+
def getPrettyLink(self, obj):
|
|
30
|
+
"""Display the description just under the pretty link."""
|
|
31
|
+
pl = super(PrettyLinkColumn, self).getPrettyLink(obj)
|
|
32
|
+
|
|
33
|
+
# simple blank space
|
|
34
|
+
blank = u'<p class="discreet"></p>'
|
|
35
|
+
|
|
36
|
+
# display description if any
|
|
37
|
+
description = safe_unicode(html.escape(obj.Description() or u'')).replace('\n', '<br/>')
|
|
38
|
+
if description:
|
|
39
|
+
description = u'<p class="discreet">{0}</p>'.format(description)
|
|
40
|
+
|
|
41
|
+
# display filename if any
|
|
42
|
+
filename = html.escape(obj.file.filename or '')
|
|
43
|
+
field_name = translate(
|
|
44
|
+
'File',
|
|
45
|
+
domain='imio.annex',
|
|
46
|
+
context=obj.REQUEST)
|
|
47
|
+
filename = u'<div class="discreet"><label class="horizontal">{0}</label>' \
|
|
48
|
+
'<div class="type-text-widget">{1}</div></div>'.format(
|
|
49
|
+
field_name, filename)
|
|
50
|
+
|
|
51
|
+
# display scan_id if any
|
|
52
|
+
scan_id = html.escape(getattr(obj, "scan_id", '') or '')
|
|
53
|
+
if scan_id:
|
|
54
|
+
field_name = translate(
|
|
55
|
+
'scan_id',
|
|
56
|
+
domain='collective.dms.scanbehavior',
|
|
57
|
+
context=obj.REQUEST)
|
|
58
|
+
scan_id = u'<div class="discreet"><label class="horizontal">{0}</label>' \
|
|
59
|
+
'<div class="type-textarea-widget">{1}</div></div>'.format(
|
|
60
|
+
field_name, scan_id)
|
|
61
|
+
return pl + blank + description + filename + scan_id
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class AuthorColumn(MemberIdColumn):
|
|
65
|
+
""" """
|
|
66
|
+
weight = IconifiedAuthorColumn.weight
|
|
67
|
+
header = IconifiedAuthorColumn.header
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class CategoryColumn(IconifiedCategoryColumn, BaseColumn):
|
|
71
|
+
""" """
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class CreationDateColumn(IconifiedCreationDateColumn, DateColumn):
|
|
75
|
+
""" """
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class LastModificationColumn(IconifiedLastModificationColumn, DateColumn):
|
|
79
|
+
""" """
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class FilesizeColumn(IconifiedFilesizeColumn, BaseColumn):
|
|
83
|
+
""" """
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class ActionsColumn(DashboardActionsColumn):
|
|
87
|
+
header = _(u'Actions')
|
|
88
|
+
weight = 100
|
|
89
|
+
params = {'showHistory': True, 'showActions': True, 'showArrows': True}
|
|
90
|
+
|
|
91
|
+
def _showArrows(self):
|
|
92
|
+
sort_categorized_tab = api.portal.get_registry_record(
|
|
93
|
+
'sort_categorized_tab',
|
|
94
|
+
interface=IIconifiedCategorySettings,
|
|
95
|
+
)
|
|
96
|
+
return not (bool(sort_categorized_tab))
|
|
97
|
+
|
|
98
|
+
def renderCell(self, item):
|
|
99
|
+
""" """
|
|
100
|
+
self.params['showArrows'] = self._showArrows()
|
|
101
|
+
return super(ActionsColumn, self).renderCell(item)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<configure
|
|
2
|
+
xmlns="http://namespaces.zope.org/zope"
|
|
3
|
+
xmlns:five="http://namespaces.zope.org/five"
|
|
4
|
+
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
|
|
5
|
+
xmlns:monkey="http://namespaces.plone.org/monkey"
|
|
6
|
+
xmlns:i18n="http://namespaces.zope.org/i18n"
|
|
7
|
+
xmlns:plone="http://namespaces.plone.org/plone"
|
|
8
|
+
xmlns:zcml="http://namespaces.zope.org/zcml"
|
|
9
|
+
i18n_domain="imio.annex">
|
|
10
|
+
|
|
11
|
+
<i18n:registerTranslations directory="locales" />
|
|
12
|
+
|
|
13
|
+
<include package="imio.helpers" />
|
|
14
|
+
<include package="imio.dashboard" />
|
|
15
|
+
<include package="imio.actionspanel" />
|
|
16
|
+
<include package="collective.dms.scanbehavior" zcml:condition="installed collective.dms.scanbehavior" />
|
|
17
|
+
<include package="collective.documentviewer" />
|
|
18
|
+
<include package="collective.iconifiedcategory" />
|
|
19
|
+
<include package="collective.quickupload" />
|
|
20
|
+
|
|
21
|
+
<include package=".browser" />
|
|
22
|
+
<include package=".content" />
|
|
23
|
+
<include package=".quickupload" />
|
|
24
|
+
|
|
25
|
+
<include file="profiles.zcml" />
|
|
26
|
+
|
|
27
|
+
<!-- IPrettyLink -->
|
|
28
|
+
<adapter for="imio.annex.content.annex.IAnnex"
|
|
29
|
+
factory=".adapters.AnnexPrettyLinkAdapter"
|
|
30
|
+
provides="imio.prettylink.interfaces.IPrettyLink" />
|
|
31
|
+
|
|
32
|
+
<!-- Columns -->
|
|
33
|
+
<adapter
|
|
34
|
+
name="number-column"
|
|
35
|
+
for="zope.interface.Interface
|
|
36
|
+
zope.interface.Interface
|
|
37
|
+
collective.iconifiedcategory.interfaces.ICategorizedTable"
|
|
38
|
+
provides="z3c.table.interfaces.IColumn"
|
|
39
|
+
factory="collective.eeafaceted.z3ctable.columns.ElementNumberColumn"
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
<!-- monkey patches -->
|
|
43
|
+
<include package="collective.monkeypatcher" />
|
|
44
|
+
|
|
45
|
+
<monkey:patch
|
|
46
|
+
description="Ensure that an event is triggered before the document conversion"
|
|
47
|
+
class="collective.documentviewer.convert.Converter"
|
|
48
|
+
original="__call__"
|
|
49
|
+
replacement=".patch.converter_call"
|
|
50
|
+
preserveOriginal="true" />
|
|
51
|
+
|
|
52
|
+
<monkey:patch
|
|
53
|
+
description="Ensure that an event is triggered before the document conversion"
|
|
54
|
+
class="collective.documentviewer.async.JobRunner"
|
|
55
|
+
original="queue_it"
|
|
56
|
+
replacement=".patch.jobrunner_queue_it"
|
|
57
|
+
preserveOriginal="true" />
|
|
58
|
+
|
|
59
|
+
<!-- behaviors -->
|
|
60
|
+
<plone:behavior zcml:condition="installed collective.dms.scanbehavior"
|
|
61
|
+
title="Scan metadata (fields to_sign/signed hidden)"
|
|
62
|
+
description="Adds scan information fields but hides fields to_sign/signed"
|
|
63
|
+
provides=".behaviors.IScanFieldsHiddenToSignAndSigned" />
|
|
64
|
+
|
|
65
|
+
</configure>
|
|
File without changes
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
imio.annex
|
|
4
|
+
----------
|
|
5
|
+
|
|
6
|
+
Created by mpeeters
|
|
7
|
+
:license: GPL, see LICENCE.txt for more details.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from imio.annex import _
|
|
11
|
+
from plone.app.contenttypes.content import File
|
|
12
|
+
from plone.app.contenttypes.interfaces import IFile
|
|
13
|
+
from plone.app.dexterity import PloneMessageFactory as _PMF
|
|
14
|
+
from plone.autoform import directives as form
|
|
15
|
+
from plone.dexterity.schema import DexteritySchemaPolicy
|
|
16
|
+
from plone.namedfile.field import NamedBlobFile
|
|
17
|
+
from plone.supermodel import model
|
|
18
|
+
from plone.uuid.interfaces import ATTRIBUTE_NAME
|
|
19
|
+
from z3c.form.interfaces import IAddForm
|
|
20
|
+
from z3c.form.interfaces import IEditForm
|
|
21
|
+
from zope import schema
|
|
22
|
+
from zope.interface import implements
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class IAnnex(model.Schema, IFile):
|
|
26
|
+
"""Schema for Annex content type"""
|
|
27
|
+
|
|
28
|
+
title = schema.TextLine(
|
|
29
|
+
title=_PMF(u'label_title', default=u'Title'),
|
|
30
|
+
required=False,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
description = schema.Text(
|
|
34
|
+
title=_PMF(u'label_description', default=u'Summary'),
|
|
35
|
+
description=_PMF(
|
|
36
|
+
u'help_description',
|
|
37
|
+
default=u'Used in item listings and search results.'
|
|
38
|
+
),
|
|
39
|
+
required=False,
|
|
40
|
+
missing_value=u'',
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
form.order_before(description='*')
|
|
44
|
+
form.order_before(title='*')
|
|
45
|
+
|
|
46
|
+
form.omitted('title', 'description')
|
|
47
|
+
form.no_omit(IEditForm, 'title', 'description')
|
|
48
|
+
form.no_omit(IAddForm, 'title', 'description')
|
|
49
|
+
|
|
50
|
+
model.primary('file')
|
|
51
|
+
file = NamedBlobFile(
|
|
52
|
+
title=_(u'File'),
|
|
53
|
+
required=True,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class Annex(File):
|
|
58
|
+
"""Annex content type"""
|
|
59
|
+
implements(IAnnex)
|
|
60
|
+
|
|
61
|
+
def UID(self):
|
|
62
|
+
"""Speedup getting UID."""
|
|
63
|
+
return getattr(self, ATTRIBUTE_NAME)
|
|
64
|
+
|
|
65
|
+
def show_download(self):
|
|
66
|
+
"""Condition to show the "Download" action."""
|
|
67
|
+
res = True
|
|
68
|
+
parent = self.aq_parent
|
|
69
|
+
element = parent.categorized_elements[self.UID()]
|
|
70
|
+
# preview with protected download
|
|
71
|
+
if element['show_preview'] == 2:
|
|
72
|
+
infos = parent.unrestrictedTraverse('@@categorized-childs-infos')
|
|
73
|
+
res = infos.show_download(element)
|
|
74
|
+
return res
|
|
75
|
+
|
|
76
|
+
def show_preview(self):
|
|
77
|
+
"""Condition to show the "Preview" action."""
|
|
78
|
+
return self.aq_parent.categorized_elements[self.UID()]['preview_status'] == 'converted'
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class AnnexSchemaPolicy(DexteritySchemaPolicy):
|
|
82
|
+
"""Schema Policy for Annex"""
|
|
83
|
+
|
|
84
|
+
def bases(self, schema_name, tree):
|
|
85
|
+
return (IAnnex, )
|