Пример #1
0
 def update_from_json(self, json):
     self.gid = json.get('id')
     self.tipo = json.get('tipo')
     self.c_estimado = json.get('c_estimado')
     update_array(self.reses,
                  json.get('reses'),
                  ActividadesReses.create_from_json)
Пример #2
0
    def update_from_json(self, json):
        self.gid = json.get('id')
        self.tipo = json.get('tipo')
        update_array(self.cultivos,
                     json.get('cultivos'),
                     ActividadesCultivos.create_from_json)
        next_cult_id_sequence = self.calculate_next_sequence(self.cultivos)
        for cultivo in self.cultivos:
            if not cultivo.cult_id:
                cultivo.cult_id = json.get('exp_id') + '-{:03d}'.format(next_cult_id_sequence)
                next_cult_id_sequence += 1

        # self.c_estimado = json.get('c_estimado')
        self.c_estimado = reduce(lambda x,y: x + y.c_estimado, self.cultivos, 0)
Пример #3
0
    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