summaryrefslogtreecommitdiff
path: root/addons/pad/web
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2011-10-13 19:03:27 +0200
committerOlivier Dony <odo@openerp.com>2011-10-13 19:03:27 +0200
commit3bffe65b2ca8bc50ece644e7947ad2bbd5c9341a (patch)
treeb307874680dbdce7b2f5109b7b696ea38e679e20 /addons/pad/web
parenta93ca01b5b1365f92e191e3c429ef655e751b455 (diff)
parent8a7c61cb96a541a9aaca51ffe3ee903407b26360 (diff)
[MERGE] sync with latest trunk
bzr revid: odo@openerp.com-20111013170327-9rvfdkbgj01hdgxb
Diffstat (limited to 'addons/pad/web')
-rw-r--r--addons/pad/web/__init__.py2
-rw-r--r--addons/pad/web/controllers.py37
-rw-r--r--addons/pad/web/editors.py46
3 files changed, 0 insertions, 85 deletions
diff --git a/addons/pad/web/__init__.py b/addons/pad/web/__init__.py
deleted file mode 100644
index 95542e91e3e..00000000000
--- a/addons/pad/web/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-import controllers
-import editors
diff --git a/addons/pad/web/controllers.py b/addons/pad/web/controllers.py
deleted file mode 100644
index 082ab69b35a..00000000000
--- a/addons/pad/web/controllers.py
+++ /dev/null
@@ -1,37 +0,0 @@
-import urlparse
-
-import cherrypy
-
-from openobject import rpc
-from openobject.tools import expose
-
-import openerp.controllers
-from openerp.utils import TinyDict
-
-class Piratepad(openerp.controllers.SecuredController):
- _cp_path = "/piratepad"
-
- def get_root(self):
- return rpc.RPCProxy('res.company').read(
- [rpc.get_session().company_id], ['pad_index'])[0]['pad_index']
-
- def make_url(self, pad_name):
- return urlparse.urljoin(
- self.get_root(), '-'.join(pad_name.split())
- )
-
- @expose('json', methods=('POST',))
- def link(self, pad_name):
- params, data = TinyDict.split(cherrypy.session['params'])
- ctx = dict(rpc.get_session().context,
- default_res_model=params.model, default_res_id=params.id,
- active_id=False, active_ids=[])
-
- pad_name = pad_name.decode('utf8')
- pad_link = self.make_url(pad_name)
- attachment_id = rpc.RPCProxy('ir.attachment').create({
- 'name': pad_name,
- 'url': pad_link,
- 'type': 'url'
- }, ctx)
- return {'id': attachment_id, 'name': pad_name, 'url': pad_link}
diff --git a/addons/pad/web/editors.py b/addons/pad/web/editors.py
deleted file mode 100644
index e303dc4b3d7..00000000000
--- a/addons/pad/web/editors.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# -*- coding: utf-8 -*-
-import openobject.templating
-
-class SidebarTemplateEditor(openobject.templating.TemplateEditor):
- templates = ['/openerp/widgets/templates/sidebar.mako']
- ADD_ATTACHMENT_BUTTON = u'id="add-attachment"'
- BINARY_ATTACHMENTS_FORM = u'<form id="attachment-box"'
-
- def insert_pad_link(self, output):
- # Insert the link on the line right after the link to open the
- # attachment form
- form_opener_insertion = output.index(
- '\n',
- output.index(self.ADD_ATTACHMENT_BUTTON)) + 1
- output = output[:form_opener_insertion] + \
- '''<a href="#" id="add-pad" class="button-a
- attachment-button">${_("Write")}</a>\n''' + \
- output[form_opener_insertion:]
- return output
-
- def edit(self, template, template_text):
- output = super(SidebarTemplateEditor, self).edit(template, template_text)
-
- output = self.insert_pad_link(output)
-
- form_insertion_point = output.index(self.BINARY_ATTACHMENTS_FORM)
- return output[:form_insertion_point] + '''
- <form id="pad-form" action="/piratepad/link" method="post">
- <label for="sidebar_pad_datas">${_("Name")}:</label>
- <input id="sidebar_pad_datas"
- name="pad_name" size="5" />
- <button>${_("Ok")}</button>
- </form>
- <script type="text/javascript">
- jQuery(document).ready(function() {
- var $padForm = jQuery('#pad-form')
- .hide()
- .submit(createAttachment);
- jQuery('#add-pad').click(function(e){
- $padForm.show();
- jQuery('#sidebar_pad_datas').focus();
- e.preventDefault();
- });
- });
- </script>
- ''' + output[form_insertion_point:]