Browse Source

publish muk_utils - 12.0

pull/30/head
MuK IT GmbH 6 years ago
parent
commit
6fab2c0886
  1. 1
      muk_utils/__init__.py
  2. 2
      muk_utils/__manifest__.py
  3. 20
      muk_utils/controllers/__init__.py
  4. 50
      muk_utils/controllers/backend.py

1
muk_utils/__init__.py

@ -17,6 +17,5 @@
#
###################################################################################
from . import controllers
from . import models
from . import tools

2
muk_utils/__manifest__.py

@ -19,7 +19,7 @@
{
"name": "MuK Utils",
"summary": """Utility Features""",
"version": '12.0.1.6.17',
"version": '12.0.1.6.18',
"category": 'Extra Tools',
"license": "AGPL-3",
"author": "MuK IT",

20
muk_utils/controllers/__init__.py

@ -1,20 +0,0 @@
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
from . import backend

50
muk_utils/controllers/backend.py

@ -1,50 +0,0 @@
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
import json
import base64
import logging
from odoo import http
from odoo.http import request
_logger = logging.getLogger(__name__)
class BackendController(http.Controller):
@http.route('/utils/attachment/add', type='http', auth="user", methods=['POST'])
def add_attachment(self, ufile=None, **kw):
content = ufile.read()
attachment = request.env['ir.attachment'].create({
'name': "Access Attachment: %s" % ufile.filename,
'datas': base64.b64encode(content),
'datas_fname': ufile.filename,
'type': 'binary',
'public': False,
})
attachment.generate_access_token()
base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
result = attachment.read(['name', 'datas_fname', 'mimetype', 'checksum', 'access_token'])[0]
result['url'] = '%s/web/content/%s?access_token=%s' % (base_url, attachment.id, attachment.access_token)
return json.dumps(result)
@http.route('/utils/attachment/remove', type='http', auth="user", methods=['POST'])
def remove_attachment(self, id, **kw):
return json.dumps(request.env['ir.attachment'].browse(id).unlink())
Loading…
Cancel
Save