mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[10.0][ADD][web_chatter_paste] (#548)
* Initial commit * Initial commit * [ADD] Tests * [FIX] Dependencies * [REM] Controller tests * [FIX] Removed unnecessary incompatibility warning * [FIX] Hyperlink to issues * [ADD] Tests * [FIX] Tests * [?] Testing test problem * [?] Testing test problem * [?] Testing test problem * [ADD] web_chatter_paste Initial commit Initial commit [ADD] Tests [FIX] Dependencies [REM] Controller tests [FIX] Removed unnecessary incompatibility warning [FIX] Hyperlink to issues [ADD] Tests [FIX] Tests [?] Testing test problem [?] Testing test problem [?] Testing test problem * Testing problem * Testing problem * Testing problem * [ADD] Mock for http.request * [FIX] Use patch to mock
This commit is contained in:
committed by
Dave Lasley
parent
b5d7d1a9d4
commit
0ac40527cd
5
web_chatter_paste/controllers/__init__.py
Normal file
5
web_chatter_paste/controllers/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import main
|
||||
33
web_chatter_paste/controllers/main.py
Normal file
33
web_chatter_paste/controllers/main.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import http
|
||||
from json import dumps
|
||||
|
||||
|
||||
class ChatterPasteController(http.Controller):
|
||||
|
||||
@http.route('/web_chatter_paste/upload_attachment', type='http',
|
||||
auth="user")
|
||||
def upload_attachment(self, callback, model, id, filename, mimetype,
|
||||
content):
|
||||
request = http.request
|
||||
model_obj = request.env['ir.attachment']
|
||||
out = """<script language="javascript" type="text/javascript">
|
||||
var win = window.top.window;
|
||||
win.jQuery(win).trigger(%s, %s);
|
||||
</script>"""
|
||||
attachment = model_obj.create({
|
||||
'name': filename,
|
||||
'datas': content,
|
||||
'datas_fname': filename,
|
||||
'res_model': model,
|
||||
'res_id': int(id)
|
||||
})
|
||||
args = {
|
||||
'filename': filename,
|
||||
'mimetype': mimetype,
|
||||
'id': attachment.id
|
||||
}
|
||||
return out % (dumps(callback), dumps(args))
|
||||
Reference in New Issue
Block a user