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)
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)
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)
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 })