Пример #1
0
    def removerProjeto(self, ID_PROJETO):
        """
        Dada uma entrada na tabela PROJETOS, a função busca e remove essa entrada após buscar e remover o DOCUMENTO
        relacionado, os partifipantes deste projeto, seu orgão e classificação

        :param ID_PROJETO: Identificador único de uma entrada na tabela PROJETOS
        """
        projeto = self.getProjeto(ID_PROJETO)
        SIEParticipantesProjs().removerParticipantesFromProjeto(
            projeto['ID_PROJETO'])
        SIEOrgaosProjetos().removerOrgaosProjetosDeProjeto(
            projeto['ID_PROJETO'])
        SIEClassifProjetos().removerClassifProjetosDeProjeto(
            projeto['ID_PROJETO'])

        if projeto["ID_DOCUMENTO"]:
            # Se existe documento relacionado a este documento.
            documento = SIEDocumentoDAO().obter_documento(
                projeto['ID_DOCUMENTO'])
            SIEDocumentoDAO().remover_documento(documento)
        else:
            #print "Nenhum documento relacionado ao projeto %d" % ID_PROJETO # TODO Colocar logging?
            pass

        self.api.delete(self.path, {"ID_PROJETO": ID_PROJETO})
Пример #2
0
    def registrar_projeto(self, id_projeto):
        """
        Cria o documento e tramita para DPQ. Muda status do projeto tb.
        :param id_projeto:
        :return:
        :rtype: bool
        """

        #verificar se tem classificações
        classificacoes_projeto = SIEClassifProjetos().get_classificacoes_cnpq(id_projeto)
        grupos_projeto = SIEClassifProjetos().get_grupos_cnpq(id_projeto)
        camara_pesquisa = SIEClassifProjetos().get_camara_pesquisa(id_projeto)

        if not camara_pesquisa or not classificacoes_projeto or not grupos_projeto:
            raise SIEException("Projeto não cadastrado. Favor informar as classificações na aba anterior.")


        documento_projeto = self.documento_inicial_padrao()
        documentoDAO = SIEDocumentoDAO()
        documento = documentoDAO.criar_documento(documento_projeto)  # PASSO 1

        # marcando a maneira de lidar com o fluxo caso o destino esteja em uma query (IND_QUERY='S')
        # resolvedor_destino = lambda fluxo: self.resolve_destino_tramitacao(fluxo, id_projeto) # Era usado anteriormente. Deixando aqui pois pode server para depois.

        # faz a primeira tramitação
        fluxo = documentoDAO.obter_fluxo_inicial(documento)
        documentoDAO.tramitar_documento(documento, fluxo)

        projeto = {
            "ID_PROJETO": id_projeto,
            "ID_DOCUMENTO": documento['ID_DOCUMENTO'],
            "NUM_PROCESSO": documento['NUM_PROCESSO']
        }

        return self.atualizar_projeto(projeto)
Пример #3
0
    def is_avaliacao_com_professor(self,avaliacao):
        """
        Método retorna se a avaliação passada como parâmetro está com o professor ( e o mesmo pode reenviar relatório) ou não.

        :param avaliacao: avaliação contendo ID_DOCUMENTO obrigatoriamente.
        :type avaliacao: dict
        """

        id_documento_avaliacao = avaliacao["ID_DOCUMENTO"]

        documento_avaliacao = SIEDocumentoDAO().obter_documento(id_documento_avaliacao)

        return int(documento_avaliacao['SITUACAO_ATUAL']) == self.COD_SITUACAO_COM_COORDENADOR
Пример #4
0
    def salvarProjeto(self, projeto, funcionario, edicao):
        """
        EVENTO_TAB              => Tipos de Eventos
        EVENTO_ITEM = 1         => Não se aplica
        TIPO_PUBLICO_TAB        => Público alvo
        TIPO_PUBLICO_ITEM = 8   => 3o grau
        AVALIACAO_TAB           => Avaliação dos projetos da Instituição
        AVALIACAO_ITEM = 2      => Pendente de avaliacao

        :type projeto: dict
        :param projeto: Um projeto a ser inserido no banco
        :type funcionario: dict
        :param funcionario: Dicionário de IDS de um funcionário
        :type edicao: gluon.storage.Storage
        :param edicao: Uma entrada da tabela `edicao`
        :return: Um dicionário contendo a entrada uma nova entrada da tabela PROJETOS
        """
        novoDocumento = SIEDocumentoDAO().criar_documento(215, funcionario)
        projeto.update({
            "ID_DOCUMENTO":
            novoDocumento["ID_DOCUMENTO"],
            "ID_UNIDADE":
            SIECursosDisciplinas().getIdUnidade(projeto['ID_CURSO']),
            "NUM_PROCESSO":
            novoDocumento["NUM_PROCESSO"],
            "EVENTO_TAB":
            6028,
            "EVENTO_ITEM":
            1,
            "TIPO_PUBLICO_TAB":
            6002,
            "TIPO_PUBLICO_ITEM":
            8,
            "ACESSO_PARTICIP":
            "S",
            "PAGA_BOLSA":
            "S",
            "DT_INICIAL":
            edicao.dt_inicial_projeto,
            "DT_REGISTRO":
            date.today(),
            "AVALIACAO_TAB":
            6010,
            "AVALIACAO_ITEM":
            2
        })

        novoProjeto = self.api.post(self.path, projeto)
        projeto.update({"ID_PROJETO": novoProjeto.insertId})

        return projeto
Пример #5
0
class TestDocumento(SIETestCase):
    DUMMY_INVALID_ID = 857893245934

    def __init__(self, *args, **kwargs):
        super(TestDocumento, self).__init__(*args, **kwargs)

        from sie.SIEDocumento import SIEDocumentoDAO
        from sie.SIEFuncionarios import SIEFuncionarioID

        self.documento_valido = self.api.get(SIEDocumentoDAO.path).first()
        self.funcionario_dummy = self.api.get(SIEFuncionarioID.path).first()

    def setUp(self):
        from sie.SIEDocumento import SIEDocumentoDAO

        self.dao = SIEDocumentoDAO()

    def test_criar_documento_projeto_pesquisa(self):
        from sie.SIEProjetosPesquisa import SIEProjetosPesquisa

        dao_projetos = SIEProjetosPesquisa()
        documento = self.dao.criar_documento(
            self.funcionario_dummy, dao_projetos.documento_inicial_padrao(self.funcionario_dummy)
        )
        self.assertIsInstance(documento, dict)
        self.dao.remover_documento(documento)  # clean poopie

    def test_criar_documento_params_vazios(self):
        with self.assertRaises(KeyError):
            from sie.SIEProjetos import SIEProjetos

            dao_projetos = SIEProjetos()
            documento = self.dao.criar_documento(self.funcionario_dummy, dict())
            # devo tentar apagar o documento?

    def test_obter_documento(self):
        documento = self.dao.obter_documento(2654)
        self.assertIsInstance(documento, dict)

    def test_obter_documento_id_errado(self):
        with self.assertRaises(Exception):
            documento = self.dao.obter_documento(self.DUMMY_INVALID_ID)

    def test_remover_documento(self):
        from sie.SIEProjetosPesquisa import SIEProjetosPesquisa

        dao_projetos = SIEProjetosPesquisa()
        documento = self.dao.criar_documento(
            self.funcionario_dummy, dao_projetos.documento_inicial_padrao(self.funcionario_dummy)
        )
        self.dao.remover_documento(documento)
        # test passed

    def test_atualizar_situacao_documento(self):
        self.fail("Test not implemented")  # TODO implement this!

    # === Tramitacao =======================================================================================================

    def test_tramitar_documento(self):
        self.fail("Test not implemented")  # TODO implement this!

    def test_tramitar_documento_algum_param_nulo(self):
        self.fail("Test not implemented")  # TODO implement this!

    def test_obter_tramitacao_atual(self):
        self.assertIsInstance(self.dao.obter_tramitacao_atual(self.documento_valido), dict)

    def test_remover_tramitacoes(self):
        self.fail("Test not implemented")  # TODO implement this!

    # === Fluxo ============================================================================================================

    def test_obter_fluxo_tramitacao_atual(self):
        self.assertIsInstance(self.dao.obter_fluxo_tramitacao_atual(self.documento_valido), dict)

    def test_obter_fluxo_tramitacao_atual_doc_vazio(self):
        with self.assertRaises(KeyError):
            self.dao.obter_fluxo_tramitacao_atual(dict())

    def test_obter_proximos_fluxos_tramitacoes_atual(self):
        fluxos = self.dao.obter_proximos_fluxos_tramitacao_validos(self.documento_valido)
        self.assertIsInstance(fluxos, list)
        for obj in fluxos:
            self.assertIsInstance(obj, dict)

    # === _NumProcessoHandler ==============================================================================================

    def __get_ultimo_numero_processo(self):
        return self.dao.api.get_single_result(
            "NUMEROS_TIPO_DOC",
            {"ID_TIPO_DOC": self.documento_valido["ID_TIPO_DOC"], "ANO_TIPO_DOC": date.today().year},
            ["NUM_ULTIMO_DOC"],
        )["NUM_ULTIMO_DOC"]

    def test_gerar_numero_processo(self):

        previous_value = self.__get_ultimo_numero_processo()

        from sie.SIEDocumento import _NumeroProcessoTipoDocumentoDAO

        handler = _NumeroProcessoTipoDocumentoDAO(self.documento_valido["ID_TIPO_DOC"], self.funcionario_dummy)
        handler.gerar_numero_processo()

        new_value = self.__get_ultimo_numero_processo()
        self.assertEqual(previous_value + 1, new_value)
        try:
            handler.reverter_ultimo_numero_processo()
        except Exception:
            pass

    def test_reverter_ultimo_numero_processo(self):
        from sie.SIEDocumento import _NumeroProcessoTipoDocumentoDAO

        handler = _NumeroProcessoTipoDocumentoDAO(self.documento_valido["ID_TIPO_DOC"], self.funcionario_dummy)
        try:
            handler.gerar_numero_processo()
        except Exception:
            pass
        previous_value = self.__get_ultimo_numero_processo()
        handler.reverter_ultimo_numero_processo()
        new_value = self.__get_ultimo_numero_processo()
        self.assertEqual(previous_value - 1, new_value)
Пример #6
0
    def setUp(self):
        from sie.SIEDocumento import SIEDocumentoDAO

        self.dao = SIEDocumentoDAO()
Пример #7
0
class TestDocumento(SIETestCase):
    DUMMY_INVALID_ID = 857893245934

    def __init__(self, *args, **kwargs):
        super(TestDocumento, self).__init__(*args, **kwargs)

        from sie.SIEDocumento import SIEDocumentoDAO
        from sie.SIEFuncionarios import SIEFuncionarioID

        self.documento_valido = self.api.get(SIEDocumentoDAO.path).first()
        self.funcionario_dummy = self.api.get(SIEFuncionarioID.path).first()

    def setUp(self):
        from sie.SIEDocumento import SIEDocumentoDAO
        self.dao = SIEDocumentoDAO()

    def test_criar_documento_projeto_pesquisa(self):
        from sie.SIEProjetosPesquisa import SIEProjetosPesquisa
        dao_projetos = SIEProjetosPesquisa()
        documento = self.dao.criar_documento(self.funcionario_dummy, dao_projetos.documento_inicial_padrao(self.funcionario_dummy))
        self.assertIsInstance(documento, dict)
        self.dao.remover_documento(documento)  # clean poopie

    def test_criar_documento_params_vazios(self):
        with self.assertRaises(KeyError):
            from sie.SIEProjetos import SIEProjetos
            dao_projetos = SIEProjetos()
            documento = self.dao.criar_documento(self.funcionario_dummy, dict())
            # devo tentar apagar o documento?

    def test_obter_documento(self):
        documento = self.dao.obter_documento(2654)
        self.assertIsInstance(documento, dict)

    def test_obter_documento_id_errado(self):
        with self.assertRaises(Exception):
            documento = self.dao.obter_documento(self.DUMMY_INVALID_ID)

    def test_remover_documento(self):
        from sie.SIEProjetosPesquisa import SIEProjetosPesquisa
        dao_projetos = SIEProjetosPesquisa()
        documento = self.dao.criar_documento(self.funcionario_dummy, dao_projetos.documento_inicial_padrao(self.funcionario_dummy))
        self.dao.remover_documento(documento)
        # test passed

    def test_atualizar_situacao_documento(self):
        self.fail("Test not implemented")  # TODO implement this!

# === Tramitacao =======================================================================================================

    def test_tramitar_documento(self):
        self.fail("Test not implemented")  # TODO implement this!

    def test_tramitar_documento_algum_param_nulo(self):
        self.fail("Test not implemented")  # TODO implement this!

    def test_obter_tramitacao_atual(self):
        self.assertIsInstance(self.dao.obter_tramitacao_atual(self.documento_valido), dict)

    def test_remover_tramitacoes(self):
        self.fail("Test not implemented")  # TODO implement this!

# === Fluxo ============================================================================================================

    def test_obter_fluxo_tramitacao_atual(self):
        self.assertIsInstance(self.dao.obter_fluxo_tramitacao_atual(self.documento_valido), dict)

    def test_obter_fluxo_tramitacao_atual_doc_vazio(self):
        with self.assertRaises(KeyError):
            self.dao.obter_fluxo_tramitacao_atual(dict())

    def test_obter_proximos_fluxos_tramitacoes_atual(self):
        fluxos = self.dao.obter_proximos_fluxos_tramitacao_validos(self.documento_valido)
        self.assertIsInstance(fluxos, list)
        for obj in fluxos:
            self.assertIsInstance(obj, dict)

# === _NumProcessoHandler ==============================================================================================

    def __get_ultimo_numero_processo(self):
            return self.dao.api.get_single_result("NUMEROS_TIPO_DOC", {"ID_TIPO_DOC": self.documento_valido["ID_TIPO_DOC"], "ANO_TIPO_DOC": date.today().year}, ["NUM_ULTIMO_DOC"])["NUM_ULTIMO_DOC"]

    def test_gerar_numero_processo(self):

        previous_value = self.__get_ultimo_numero_processo()

        from sie.SIEDocumento import _NumeroProcessoTipoDocumentoDAO
        handler = _NumeroProcessoTipoDocumentoDAO(self.documento_valido["ID_TIPO_DOC"], self.funcionario_dummy)
        handler.gerar_numero_processo()

        new_value = self.__get_ultimo_numero_processo()
        self.assertEqual(previous_value + 1, new_value)
        try:
            handler.reverter_ultimo_numero_processo()
        except Exception:
            pass

    def test_reverter_ultimo_numero_processo(self):
        from sie.SIEDocumento import _NumeroProcessoTipoDocumentoDAO
        handler = _NumeroProcessoTipoDocumentoDAO(self.documento_valido["ID_TIPO_DOC"], self.funcionario_dummy)
        try:
            handler.gerar_numero_processo()
        except Exception:
            pass
        previous_value = self.__get_ultimo_numero_processo()
        handler.reverter_ultimo_numero_processo()
        new_value = self.__get_ultimo_numero_processo()
        self.assertEqual(previous_value - 1, new_value)
Пример #8
0
 def setUp(self):
     from sie.SIEDocumento import SIEDocumentoDAO
     self.dao = SIEDocumentoDAO()
Пример #9
0
    def enviar_relatorio_docente(self, relatorio, params_projeto):

        documento_dao = SIEDocumentoDAO()

        avaliacao = SIEAvaliacaoProjsPesquisaDAO().get_avaliacao(params_projeto['ANO_REF_AVAL'],relatorio.id_projeto,params_projeto["PERIODO_REF_TAB"],params_projeto["PERIODO_REF_ITEM"])
        if avaliacao:
            avaliacao_com_professor = SIEAvaliacaoProjsPesquisaDAO().is_avaliacao_com_professor(avaliacao)
            if not avaliacao_com_professor:
                raise SIEException("Já há avaliação cadastrada para este projeto neste período de avaliação. Caso queira enviar outra avaliação, entre em contato com a DPq.")
            else:
                #Salva relatorio
                arquivo_salvo = SIEArquivosProj().salvar_arquivo(nome_arquivo=relatorio.filename,
                                                             arquivo=relatorio.arquivo,
                                                             id_projeto=relatorio.id_projeto,
                                                             tipo_arquivo=SIEArquivosProj.ITEM_TIPO_ARQUIVO_RELATORIO_DOCENTE)

                # atualizar ref tabela de arquivos com id da avaliacao
                SIEArquivosProj().atualizar_arquivo(arquivo_salvo["ID_ARQUIVO_PROJ"],
                                                {"ID_AVALIACAO_PROJ": avaliacao["ID_AVALIACAO_PROJ"]})

                #obtem estado atual
                documento = documento_dao.obter_documento(avaliacao["ID_DOCUMENTO"])
                tramitacao_atual = documento_dao.obter_tramitacao_atual(documento)

                #recebe documento se necessario
                if tramitacao_atual["SITUACAO_TRAMIT"]==SIEDocumentoDAO.TRAMITACAO_SITUACAO_ENTREGUE:
                    documento_dao.receber_documento(documento)
                elif tramitacao_atual["SITUACAO_TRAMIT"]==SIEDocumentoDAO.TRAMITACAO_SITUACAO_AGUARDANDO:
                    #Só tramitar
                    pass
                else:
                    #Shouldn't fall here.
                    raise NotImplementedError

                # tramita para DPq de novo.
                fluxo = documento_dao.obter_fluxo_inicial(documento) #TODO É o fluxo inicial? Me parece ser! Senão seria o último.
                documento_dao.tramitar_documento(documento, fluxo)

        else:
            #Salva relatorio
            arquivo_salvo = SIEArquivosProj().salvar_arquivo(nome_arquivo=relatorio.filename,
                                                             arquivo=relatorio.arquivo,
                                                             id_projeto=relatorio.id_projeto,
                                                             tipo_arquivo=SIEArquivosProj.ITEM_TIPO_ARQUIVO_RELATORIO_DOCENTE)

            #cria documento avaliacao
            documento_avaliacao = SIEAvaliacaoProjsPesquisaDAO().documento_inicial_padrao()
            projeto =  self.get_projeto(relatorio.id_projeto)
            documento_avaliacao.update({
                "RESUMO_ASSUNTO": "Projeto n"+u"\u00BA " + projeto['NUM_PROCESSO'].strip() # Parece ser.
            })
            documento = documento_dao.criar_documento(documento_avaliacao)  # PASSO 1

            # cria avaliacao para o arquivo
            avaliacao = SIEAvaliacaoProjsPesquisaDAO().criar_avaliacao(projeto,documento,params_projeto,data_prorrogacao=relatorio.nova_data_conclusao,obs=relatorio.obs)

            # atualizar ref tabela de arquivos com id da avaliacao
            SIEArquivosProj().atualizar_arquivo(arquivo_salvo["ID_ARQUIVO_PROJ"],
                                                {"ID_AVALIACAO_PROJ": avaliacao["ID_AVALIACAO_PROJ"]})


            # tramita para a câmara
            fluxo = documento_dao.obter_fluxo_inicial(documento)
            documento_dao.tramitar_documento(documento, fluxo)

            #atualizar projeto com avaliacao_item pendente.
            self.atualizar_projeto({
                "ID_PROJETO":relatorio.id_projeto,
                "AVALIACAO_ITEM": SIEProjetosPesquisa.ITEM_AVALIACAO_PROJETOS_INSTITUICAO_PENDENTE_AVALIACAO
            })