Browse Source

update

pull/6/head
Mathias Markl 7 years ago
parent
commit
62d7d84127
  1. 2
      muk_converter/__manifest__.py
  2. 2
      muk_converter/wizards/convert.py
  3. 2
      muk_utils/__manifest__.py
  4. 16
      muk_utils/http.py

2
muk_converter/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Converter",
"summary": """Universal Converter""",
"version": '11.0.1.1.0',
"version": '11.0.1.1.1',
"category": 'Extra Tools',
"license": "AGPL-3",
"website": "https://www.mukit.at",

2
muk_converter/wizards/convert.py

@ -102,7 +102,7 @@ class ConverterWizard(models.TransientModel):
if extension not in converter.imports():
raise ValueError("Invalid import format.")
else:
return export(record, content, "%s.%s" % (uuid.uuid4(), extension))
return export(record, content, record.input_name or "%s.%s" % (uuid.uuid4(), extension))
elif record.input_name and record.input_binary:
return export(record, base64.b64decode(record.input_binary), record.input_name)
else:

2
muk_utils/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Utils",
"summary": """Utility Features""",
"version": '11.0.1.0.0',
"version": '11.0.1.0.1',
"category": 'Extra Tools',
"license": "AGPL-3",
"website": "https://www.mukit.at",

16
muk_utils/http.py

@ -24,6 +24,7 @@ import requests
import werkzeug
from odoo.http import request
from odoo.tools import config
_logger = logging.getLogger(__name__)
@ -37,7 +38,7 @@ def get_route(url):
params = dict(urllib.parse.parse_qsl(query_string))
if len(match) > 1:
params.update(match[1])
return method, params
return method, params, path
def make_error_response(status, message):
exception = werkzeug.exceptions.HTTPException()
@ -47,9 +48,16 @@ def make_error_response(status, message):
def get_response(url):
if not bool(urllib.parse.urlparse(url).netloc):
method, params = get_route(url)
response = method(**params)
return response.status_code, response.headers, response.data
base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
method, params, path = get_route(url)
params.update({'csrf_token': request.csrf_token()})
session = requests.Session()
session.cookies['session_id'] = request.session.sid
try:
response = session.post("%s%s" % (base_url, path), params)
return response.status_code, response.headers, response.content
except requests.exceptions.RequestException as exception:
return exception.response.status_code, exception.response.headers, exception.response.reason
else:
try:
response = requests.get(url)

Loading…
Cancel
Save