Skip to content

Commit 3a6a01a

Browse files
committed
Added collabora compatibility
1 parent 608adf2 commit 3a6a01a

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

imio/dms/mail/adapters.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from AccessControl import getSecurityManager
44
from collective.classification.folder.interfaces import IServiceInCharge
55
from collective.classification.folder.interfaces import IServiceInCopy
6+
from collective.collabora.interfaces import IStoredFile
67
from collective.contact.core.content.held_position import IHeldPosition
78
from collective.contact.core.content.organization import IOrganization
89
from collective.contact.core.indexers import contact_source
@@ -15,6 +16,7 @@
1516
from collective.dms.basecontent.dmsfile import IDmsFile
1617
from collective.dms.mailcontent.indexers import add_parent_organizations
1718
from collective.dms.scanbehavior.behaviors.behaviors import IScanFields
19+
from collective.documentgenerator.content.pod_template import IPODTemplate
1820
from collective.task.interfaces import ITaskContent
1921
from imio.dms.mail import BACK_OR_AGAIN_ICONS
2022
from imio.dms.mail import IM_READER_SERVICE_FUNCTIONS
@@ -41,6 +43,7 @@
4143
from plone.app.contentmenu.menu import WorkflowMenu as OrigWorkflowMenu
4244
from plone.app.contenttypes.indexers import _unicode_save_string_concat
4345
from plone.indexer import indexer
46+
from plone.namedfile.file import NamedBlobFile
4447
from plone.registry.interfaces import IRegistry
4548
from plone.rfc822.interfaces import IPrimaryFieldInfo
4649
from Products.ATContentTypes.interfaces.folder import IATFolder
@@ -1043,3 +1046,30 @@ def get(self):
10431046
"title": child.title,
10441047
"UID": child.UID(),
10451048
}
1049+
1050+
1051+
@adapter(IPODTemplate)
1052+
@implementer(IStoredFile)
1053+
class StoredPodTemplate(object):
1054+
"""Access the file storage on a PODTemplate content object.
1055+
1056+
i.e. the file attribute on the content object.
1057+
"""
1058+
1059+
def __init__(self, context):
1060+
self.context = context
1061+
self.filename = context.odt_file.filename
1062+
self.contentType = context.odt_file.contentType
1063+
1064+
@property
1065+
def data(self):
1066+
return self.context.odt_file.data
1067+
1068+
@data.setter
1069+
def data(self, data):
1070+
self.context.odt_file = NamedBlobFile(
1071+
data=data, filename=self.filename, contentType=self.contentType
1072+
)
1073+
1074+
def getSize(self):
1075+
return self.context.odt_file.getSize()

imio/dms/mail/browser/configure.zcml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,22 @@
604604
permission="zope2.View"
605605
/>
606606

607+
<configure package="collective.collabora.browser">
608+
<browser:page
609+
name="collabora-edit"
610+
for="collective.documentgenerator.content.pod_template.IPODTemplate"
611+
class="collective.collabora.browser.edit.CollaboraEditView"
612+
template="templates/edit.pt"
613+
permission="zope2.View"
614+
layer="collective.collabora.interfaces.ICollectiveCollaboraLayer"
615+
/>
616+
</configure>
617+
618+
<adapter factory="imio.dms.mail.adapters.StoredPodTemplate"
619+
for="collective.documentgenerator.content.pod_template.IPODTemplate"
620+
provides="collective.collabora.interfaces.IStoredFile"
621+
/>
622+
607623
<!-- Viewlets -->
608624
<!-- common for dmsincomingmail, dmsoutgoingmail and task -->
609625
<browser:viewlet

imio/dms/mail/columns.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,13 @@ def renderCell(self, item):
323323
},
324324
)
325325
else:
326-
link_url = "%s/@@external_edit" % item.getURL()
326+
link_url = "%s/@@collabora-edit" % item.getURL()
327327
icon_name = "extedit_icon.png"
328328
link_title = translate(self.linkContent, context=self.request)
329329

330330
link_content = u"""<img title="%s" src="%s" />""" % (link_title, "%s/%s" % (self.table.portal_url, icon_name))
331331

332-
return '<a href="%s"%s%s%s>%s</a>' % (
332+
return '<a target="_blank" href="%s"%s%s%s>%s</a>' % (
333333
link_url,
334334
self.getLinkTarget(item),
335335
self.getLinkCSS(item),

0 commit comments

Comments
 (0)