Added action to get a word document out

This commit is contained in:
Frédéric Péters 2010-09-14 10:04:26 +02:00
parent 15cfc3ce3c
commit 3723c2c43d
3 changed files with 27 additions and 4 deletions

View File

@ -41,7 +41,8 @@ class AvisOdt:
fileType)
renderer = appy.pod.renderer.Renderer(
'%s/%s.odt' % (os.path.dirname(__file__), self.portal_type),
{'avis': self}, tempFileName)
{'avis': self}, tempFileName,
pythonWithUnoPath='/usr/bin/python2.6')
renderer.run()
# Tell the browser that the resulting page contains PDF
response.setHeader('Content-type', 'application/%s' % fileType)

View File

@ -3830,13 +3830,18 @@ class AvisLegis(BaseContent, AvisOdt):
typeDescription = "AvisLegis"
typeDescMsgId = 'description_edit_avis_simplif'
security.declarePublic('generateOdt')
actions = (
{'action': "string:$object_url/generateOdt",
'category': "document_actions",
'id': 'asOdt',
'name': u'Générer en ODT',
'name': u'Générer en Open Document Format',
'permissions': ("View",),
'condition': 'python:1'
},
{'action': "string:$object_url/generateDoc",
'category': "document_actions",
'id': 'asDoc',
'name': u'Générer au format Microsoft Word',
'permissions': ("View",),
'condition': 'python:1'
},
@ -3859,6 +3864,11 @@ class AvisLegis(BaseContent, AvisOdt):
'''Generates the ODT version of this advice.'''
return self._generate(RESPONSE, 'odt')
security.declarePublic('generateDoc')
def generateDoc(self, RESPONSE):
'''Generates the Doc version of this advice.'''
return self._generate(RESPONSE, 'doc')
security.declarePublic('getResponses')
def getResponses(self):
"""Returns the predefined responses that are possible for each question.

View File

@ -812,6 +812,13 @@ class AvisSimplif(BaseContent, AvisOdt):
'permissions': ("View",),
'condition': 'python:1'
},
{'action': "string:$object_url/generateDoc",
'category': "document_actions",
'id': 'asDoc',
'name': u'Générer au format Microsoft Word',
'permissions': ("View",),
'condition': 'python:1'
},
)
_at_rename_after_creation = True
@ -822,6 +829,11 @@ class AvisSimplif(BaseContent, AvisOdt):
'''Generates the ODT version of this advice.'''
return self._generate(RESPONSE, 'odt')
security.declarePublic('generateDoc')
def generateDoc(self, RESPONSE):
'''Generates the Doc version of this advice.'''
return self._generate(RESPONSE, 'doc')
security.declarePublic('getResponses')
def getResponses(self):
"""Returns the predefined responses that are possible for each question.