def json_catalog(request, domain='orunjs', packages=None): """ Return the selected language catalog as a JSON object. Receives the same parameters as javascript_catalog(), but returns a response with a JSON object of the following format: { "catalog": { # Translations catalog }, "formats": { # Language formats for date, time, etc. }, "plural": '...' # Expression for plural forms, or null. } """ locale = _get_locale(request) packages = _parse_packages(packages) catalog, plural = get_javascript_catalog(locale, domain, packages) data = { 'catalog': catalog, 'formats': get_formats(), 'plural': plural, } return jsonify(data)
def login(self): if request.method == 'POST': return jsonify( {'result': { 'success': True, 'is_authenticated': True }})
def public_query(self, id=None): if settings.PUBLIC_QUERY_ALLOWED: Query = app['ir.query'] q = Query.objects.get(id) if q.public: return jsonify({'result': Query.read(id)}) abort(403, 'Permission denied!')
def model_choices(self): data = request.json model = app[data['model']] model_field = data['kwargs'].get('model_field') if model_field: model_field = model._meta.fields[model_field] print(model_field) return jsonify(model.search_name(name=data.get('q'), count=data.get('count'), page=data.get('page')))
def logout(self): return jsonify({ 'result': { 'success': True, 'is_authenticated': False, 'next': None } })
def sync(self): data = request.json objs = data['data'] res = [] for obj in objs: svc = app[obj['service']] values = { k: v for k, v in obj['data'].items() if not k.startswith('$') } r = svc.write(values) res.append({'id': r[0], '$id': obj['$id'], 'status': 'ok'}) return jsonify({'ok': True, 'result': res})
def wrapped(*args, **kwargs): from orun.utils.json import jsonify data = request.json _id = data['id'] kwargs['params'] = data.get('params') try: r = fn(*args, **kwargs) return jsonify({ 'jsonrpc': '2.0', 'id': _id, 'result': r }) except ValidationError as e: return jsonify({ 'jsonrpc': '2.0', 'id': _id, 'error': { 'code': e.code, 'messages': e.message_dict, } }) except RPCError as e: return jsonify({ 'jsonrpc': '2.0', 'id': _id, 'error': { 'code': e.code, 'message': str(e) } }) except AssertionError as e: return jsonify({ 'jsonrpc': '2.0', 'id': _id, 'error': { 'message': str(e), } })
def logout(self): return jsonify({'result': {'success': True, 'is_authenticated': False, 'next': None}})
def login(self): if request.method == 'POST': return jsonify({'result': {'success': True, 'is_authenticated': True}})
def model_choices(self): data = request.json print(data) model = app[data['model']] return jsonify(model.search_name(name=data.get('q'), count=data.get('count'), page=data.get('page')))