def get(self, contract): contract_obj = peek.model('giscedata.polissa') contract_ids = contract_obj.search([ ('name', '=', contract) ]) if not contract_ids: res = {} else: cups_id = contract_obj.read(contract_ids[0], ['cups'])['cups'][0] cups_obj = peek.model('giscedata.cups.ps') res = cups_obj.read(cups_id, ['empowering']) return Response(json.dumps(res), mimetype='application/json')
def post(self, contract): data = request.json contract_obj = peek.model('giscedata.polissa') con_id = contract_obj.search([('name', '=', contract)]) if not con_id: return jsonify({'status': 404, 'message': 'Not Found'}), 404 cups_id = contract_obj.read(con_id, ['cups'])[0]['cups'][0] if 'empowering' not in data or not isinstance(data['empowering'], bool): return jsonify({'status': 404, 'message': 'Data missing'}), 404 cups_obj = peek.model('giscedata.cups.ps') cups_obj.write([cups_id], {'empowering': data['empowering']}) return jsonify({'status': 200, 'message': 'OK'}), 200
def post(self, cups): model = peek.model('empowering.cups.building') building_ids = model.search([('cups_id.name', '=', cups)]) data = request.json if not building_ids: cups = peek.model('giscedata.cups.ps').search([ ('name', '=', cups) ]) if not cups: return jsonify({'status': 404, 'message': 'Not Found'}), 404 data['cups_id'] = cups[0] model.create(data) else: model.write(building_ids, data) return jsonify({'status': 200, 'message': 'OK'}), 200
def get(self): lang = get_first_lang() model = peek.model('empowering.cups.building') def_fields = model.fields_get([], context={'lang': lang}) def_fields.pop('meteringPointId', None) res = jsonform(def_fields) return Response(json.dumps(res), mimetype='application/json')
def get(self, cups): model = peek.model('empowering.cups.building') cups_ids = model.search([('cups_id.name', '=', cups)]) if not cups_ids: res = {} else: res = model.read(cups_ids[0]) return Response(json.dumps(res), mimetype='application/json')
def get(self, contract): model = peek.model('empowering.modcontractual.profile') profile_ids = model.search([ ('modcontractual_id.polissa_id.name', '=', contract) ]) if not profile_ids: res = {} else: res = model.read(profile_ids[0]) return Response(json.dumps(res), mimetype='application/json')
def post(self, contract): model = peek.model('empowering.modcontractual.profile') profile_ids = model.search([ ('modcontractual_id.polissa_id.name', '=', contract) ]) data = request.json contract_obj = peek.model('giscedata.polissa') con_id = contract_obj.search([('name', '=', contract)]) if not con_id: return jsonify({'status': 404, 'message': 'Not Found'}), 404 contract = contract_obj.browse(con_id[0]) if not profile_ids: mod = contract.modcontractual_activa.id data['modcontractual_id'] = mod profile_id = model.create(data) else: profile_id = profile_ids[0] model.write([profile_id], data) contract.write({'empowering_profile': profile_id}) return jsonify({'status': 200, 'message': 'OK'}), 200
def get(self): lang = get_first_lang() model = peek.model('empowering.modcontractual.profile') def_fields = model.fields_get([], context={'lang': lang}) def_fields.pop('femalePersonsNumber', None) def_fields.pop('malePersonsNumber', None) def_fields.pop('eduLevel_sec', None) def_fields.pop('eduLevel_noStudies', None) def_fields.pop('eduLevel_prim', None) def_fields.pop('eduLevel_uni', None) res = jsonform(def_fields) return Response(json.dumps(res), mimetype='application/json')
def get(self): lang = get_first_lang() model = peek.model('giscedata.cups.ps') def_fields = model.fields_get(['empowering'], context={'lang': lang}) res = jsonform(def_fields) return Response(json.dumps(res), mimetype='application/json')