Esempio n. 1
0
def confirm_create(json, company_id):
    portal = Portal(name=json['name'], host=json['host'], portal_layout_id=json['portal_layout_id'],
           company_owner_id=company_id, divisions=[PortalDivision(**division)
           for division in json['divisions']]).create_portal()
    validation_result = portal.validate()

    if '__validation' in json:
        db = getattr(g, 'db', None)
        db.rollback()
        return validation_result
    elif len(validation_result['errors'].keys()):
        raise errors.ValidationException(validation_result)
    else:
        return {'company_id': company_id}
Esempio n. 2
0
 def function_json(*args, **kwargs):
     try:
         if 'json' in kwargs:
             del kwargs['json']
         a = request.json
         ret = func(a, *args, **kwargs)
         ret = {'data': ret, 'ok': True, 'error_code': 'ERROR_NO_ERROR'}
         # template = g.req('__translate', default='')
         # if template != '':
         #     ret['__translate'] = db(TranslateTemplate, template=template)
         return jsonify(ret)
     # except Exception as e:
     except errors.ValidationException as e:
         db = getattr(g, 'db', None)
         db.rollback()
         return jsonify({'ok': False, 'error_code': -1, 'result': e.result})
Esempio n. 3
0
 def function_json(*args, **kwargs):
     try:
         if 'json' in kwargs:
             del kwargs['json']
         a = request.json
         ret = func(a, *args, **kwargs)
         ret = {'data': ret, 'ok': True, 'error_code': 'ERROR_NO_ERROR'}
         # template = g.req('__translate', default='')
         # if template != '':
         #     ret['__translate'] = db(TranslateTemplate, template=template)
         return jsonify(ret)
     # except Exception as e:
     except errors.ValidationException as e:
         db = getattr(g, 'db', None)
         db.rollback()
         return jsonify({'ok': False, 'error_code': -1, 'result': e.result})