def update_from_json(self, json, lic_nro_sequence): self.gid = json.get('id') self.exp_id = json.get('exp_id') self.exp_name = json.get('exp_name') self.pagos = json.get('pagos') self.d_soli = to_date(json.get('d_soli')) self.observacio = json.get('observacio') self.loc_provin = json.get('loc_provin') self.loc_distri = json.get('loc_distri') self.loc_posto = json.get('loc_posto') self.loc_nucleo = json.get('loc_nucleo') self.loc_endere = json.get('loc_endere') self.loc_bacia = json.get('loc_bacia') self.loc_subaci = json.get('loc_subaci') self.loc_rio = json.get('loc_rio') self.c_soli = to_decimal(json.get('c_soli')) self.c_licencia = to_decimal(json.get('c_licencia')) self.c_real = to_decimal(json.get('c_real')) self.c_estimado = to_decimal(json.get('c_estimado')) self.the_geom = update_geom(self.the_geom, json) update_area(self, json) self.update_and_validate_activity(json) # update relationships update_array(self.fontes, json.get('fontes'), Fonte.create_from_json) update_array(self.licencias, json.get('licencias'), Licencia.create_from_json) for licencia in self.licencias: if not licencia.lic_nro: licencia.lic_nro = self.exp_id + '-{:03d}'.format(lic_nro_sequence) lic_nro_sequence += 1