Exemple #1
0
    def asosiar_riesgos_sugeridos_proyecto(self, riesgos, proyecto):
        p_h_r = ProyectoHasRiesgoDao()

        riesgo_dao = RiesgoDao()

        subcategoria_dao = SubcategoriaDao()

        categoria_dao = CategoriaDao()

        rbs_dao = RbsDao()
        rbs_controller = RbsController()
        rbs = rbs_controller.obtener_rbs_general(proyecto.gerente.gerente_id)
        rbs_model = rbs_dao.get_rbs_gerente_id(proyecto.gerente)

        for riesgo in riesgos:
            aux = riesgo_dao.obtener_riesgo(riesgo)
            sub_categoria_aux = aux.sub_categoria
            try:
                sub_aux = self.buscar_sub_categoria_by_uid(
                    rbs, sub_categoria_aux)
                if sub_aux:
                    riesgo_nuevo = riesgo_dao.registrar_riesgo(
                        aux.riesgo_nombre, "Sin Causa definida",
                        "Sin Evento definido", "Sin efecto definido", 0, 0,
                        sub_aux)
                else:
                    print("EEEEEEEEEEEE", sub_categoria_aux.categoria,
                          rbs_model)
                    print("CATENOMBRE",
                          sub_categoria_aux.categoria.categoria_nombre)
                    categoria_aux = categoria_dao.duplicar_categoria_2(
                        sub_categoria_aux.categoria, rbs_model)
                    print("CCCC", categoria_aux)
                    sub_categoria_aux = subcategoria_dao.duplicar_sub_categoria_2(
                        categoria_aux, sub_categoria_aux)
                    print("SSSSSSS", sub_categoria_aux)
                    rbs = rbs_controller.obtener_rbs_general(
                        proyecto.gerente.gerente_id)
                    print("RBSSSSS", rbs)
                    riesgo_nuevo = riesgo_dao.clonar_riesgo(
                        aux.riesgo_nombre, aux.riesgo_uid, sub_categoria_aux)
                    print("RRRRRRRR", riesgo_nuevo)
                p_h_r.registrar_proyecto_riesgo_editado(proyecto, riesgo_nuevo)
            except Exception as e:
                raise e
            finally:
                pass

        return True
Exemple #2
0
	def editar_riesgo_proyecto(self, proyecto_id, riesgo_id, nombre, causa, evento, efecto, tipo ):

		riesgo_dao = RiesgoDao()
		proyecto_dao = ProyectoDao()
		proyecto_has_riesgo_dao = ProyectoHasRiesgoDao()

		riesgo = riesgo_dao.obtener_riesgo(riesgo_id)
		proyecto = proyecto_dao.obtener_proyecto(proyecto_id)
		#print("VARIABLES", riesgo, proyecto)
		proyecto_has_riesgo = proyecto_has_riesgo_dao.get_by_riesgo_and_proyecto_2(riesgo, proyecto)
		#print("MI OBJETO", proyecto_has_riesgo)
		if proyecto_has_riesgo.is_editado == 1:
			#proyecto_has_riesgo_dao.actualizar_fecha(proyecto_has_riesgo, fecha)
			return riesgo_dao.editar_riesgo(riesgo, nombre, causa, evento, efecto, tipo, riesgo.sub_categoria)
		else:
			proyecto_has_riesgo.delete()
			riesgo_nuevo = riesgo_dao.registrar_riesgo_2(nombre, causa, evento, efecto, tipo, riesgo.sub_categoria)
			proyecto_has_riesgo_dao.registrar_proyecto_riesgo_editado(proyecto, riesgo_nuevo)
			return riesgo_nuevo
Exemple #3
0
	def obtener_riesgo(self, id):
		riesgo_dao = RiesgoDao()
		return riesgo_dao.obtener_riesgo(id)