summaryrefslogtreecommitdiff
path: root/addons/wiki/web/controllers
diff options
context:
space:
mode:
authoraag (OpenERP) <aag@tinyerp.co.in>2010-10-14 13:31:03 +0530
committeraag (OpenERP) <aag@tinyerp.co.in>2010-10-14 13:31:03 +0530
commitfabe3674a7a2d0da9dac1dadf4e7370abc2bbb20 (patch)
tree3ea9201015595747a47cea94a151ff778ed50a24 /addons/wiki/web/controllers
parent7b2e3875b1590d4efbb60b15e78503b6922bc543 (diff)
parentb7a6164e75f4c08c317ec5a64af2b8cecde62b6e (diff)
trunk merge
bzr revid: aag@tinyerp.co.in-20101014080103-58ysx9lo20h9kogo
Diffstat (limited to 'addons/wiki/web/controllers')
-rw-r--r--addons/wiki/web/controllers/__init__.py1
-rw-r--r--addons/wiki/web/controllers/wiki.py65
2 files changed, 66 insertions, 0 deletions
diff --git a/addons/wiki/web/controllers/__init__.py b/addons/wiki/web/controllers/__init__.py
new file mode 100644
index 00000000000..8c163ddd260
--- /dev/null
+++ b/addons/wiki/web/controllers/__init__.py
@@ -0,0 +1 @@
+import wiki
diff --git a/addons/wiki/web/controllers/wiki.py b/addons/wiki/web/controllers/wiki.py
new file mode 100644
index 00000000000..a40952360ed
--- /dev/null
+++ b/addons/wiki/web/controllers/wiki.py
@@ -0,0 +1,65 @@
+###############################################################################
+#
+# Copyright (C) 2007-TODAY Tiny ERP Pvt Ltd. All Rights Reserved.
+#
+# $Id$
+#
+# Developed by Tiny (http://openerp.com) and Axelor (http://axelor.com).
+#
+# The OpenERP web client is distributed under the "OpenERP Public License".
+# It's based on Mozilla Public License Version (MPL) 1.1 with following
+# restrictions:
+#
+# - All names, links and logos of Tiny, OpenERP and Axelor must be
+# kept as in original distribution without any changes in all software
+# screens, especially in start-up page and the software header, even if
+# the application source code has been changed or updated or code has been
+# added.
+#
+# - All distributions of the software must keep source code with OEPL.
+#
+# - All integrations to any other software must keep source code with OEPL.
+#
+# If you need commercial licence to remove this kind of restriction please
+# contact us.
+#
+# You can see the MPL licence at: http://www.mozilla.org/MPL/MPL-1.1.html
+#
+###############################################################################
+
+import base64
+
+import cherrypy
+
+from openobject.tools import expose
+
+from openerp.utils import rpc
+
+from openerp.controllers import SecuredController
+
+
+class WikiView(SecuredController):
+ _cp_path = "/wiki/wiki"
+
+ def get_attachment(self, **kwargs):
+ attachments = rpc.RPCProxy('ir.attachment')
+ file_name = kwargs.get('file').replace("'", '').strip()
+ id = kwargs.get('id').strip()
+
+ ids = attachments.search([('datas_fname', '=', file_name),
+ ('res_model', '=', 'wiki.wiki'),
+ ('res_id', '=', id)])
+
+ res = attachments.read(ids, ['datas'])[0].get('datas')
+ return res, file_name
+
+ @expose(content_type='application/octet')
+ def getImage(self, *kw, **kws):
+ res, _ = self.get_attachment(**kws)
+ return base64.decodestring(res)
+
+ @expose(content_type='application/octet')
+ def getfile(self, *kw, **kws):
+ res, file_name = self.get_attachment(**kws)
+ cherrypy.response.headers['Content-Disposition'] = 'filename="%s"' % (file_name,)
+ return base64.decodestring(res)