附件预览问题
This commit is contained in:
@@ -15,7 +15,7 @@ _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class preview(http.Controller):
|
||||
@http.route('/web/content/preview/<int:id>', type='http', method=['Get'], auth="public")
|
||||
@http.route('/web/content/preview/<int:id>', type='http', method=['Get'], auth="none")
|
||||
def content_preview(self, id=None):
|
||||
ir_attach = request.env['ir.attachment'].sudo()
|
||||
attach = ir_attach.browse(id)
|
||||
@@ -39,24 +39,24 @@ class preview(http.Controller):
|
||||
# html = result.value
|
||||
# return template.render(html=html)
|
||||
elif attach.mimetype in excel or word:
|
||||
# 'http://view.officeapps.live.com/op/view.aspx?src=https://oa.thtzjt.com/web/content/office_preview/'
|
||||
# office_view_url = 'http://view.officeapps.live.com/op/view.aspx?src='
|
||||
# base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
# html = f'{office_view_url}{quote(base_url + "/web/content/office_preview/" + str(attach.id))}'
|
||||
target_url = f'/onlyoffice/editor/{str(attach.id)}'
|
||||
return werkzeug.utils.redirect(target_url)
|
||||
# return werkzeug.wrappers.Response(f"""
|
||||
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
# "http://www.w3.org/TR/html4/loose.dtd">
|
||||
# <html>
|
||||
# <head>
|
||||
# <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
|
||||
# <title></title>
|
||||
# </head>
|
||||
# <body onLoad="parent.location='{html}'">
|
||||
# </body>
|
||||
# </html>
|
||||
# """, status=200, headers=[('Content-Type', 'text/html'), ('charset', 'utf-8')])
|
||||
'http://view.officeapps.live.com/op/view.aspx?src=https://oa.thtzjt.com/web/content/office_preview/'
|
||||
office_view_url = 'http://view.officeapps.live.com/op/view.aspx?src='
|
||||
base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
html = f'{office_view_url}{quote(base_url + "/web/content/office_preview/" + str(attach.id))}'
|
||||
# target_url = f'/onlyoffice/editor/{str(attach.id)}'
|
||||
# return werkzeug.utils.redirect(target_url)
|
||||
return werkzeug.wrappers.Response(f"""
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
|
||||
<title></title>
|
||||
</head>
|
||||
<body onLoad="parent.location='{html}'">
|
||||
</body>
|
||||
</html>
|
||||
""", status=200, headers=[('Content-Type', 'text/html'), ('charset', 'utf-8')])
|
||||
else:
|
||||
return werkzeug.wrappers.Response('This format is not currently supported', status=200, headers=[('Content-Type', 'text/html'),('charset','utf-8')])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user