ufjf-dcc / tcc-web

4 stars 12 forks source link

Aluno quando ativo e não tiver nenhum trabalho no semestre, inicia projeto #41

Closed lucaslarcher closed 9 years ago

lucaslarcher commented 9 years ago

em MenuController mudar a função myTCC(), ela fica assim

@Command public void myTcc() { if (getUsuario() != null && getUsuario().getTipoUsuario().getIdTipoUsuario() == Usuario.ALUNO) { if (getCurrentCalendar() != null) { if (getUsuario().isAtivo()) Executions.sendRedirect("/pages/editor.zul"); else Messagebox .show("Você ainda não possui um Trabalho cadastrado no semestre atual.\n Entre em contato com o coordenador do curso.", "Erro", Messagebox.OK, Messagebox.ERROR); } else { Messagebox.show( "Não há nenhum Calendário cadastrado no Sistema!", "Erro", Messagebox.OK, Messagebox.ERROR); } } }

e mudar o init() do EditorTccController:

@Init
public void init() {
    String tccId = Executions.getCurrent().getParameter("id");

    switch (getUsuario().getTipoUsuario().getIdTipoUsuario()) {
    case Usuario.ALUNO:
        TCC tempTCC = tccBusiness.getCurrentNotFinishedTCCByAuthor(getUsuario(),
                getCurrentCalendar());
        getUsuario().getTcc().clear();
        if (tempTCC != null) {
            getUsuario().getTcc().add(tempTCC);
            tcc = getUsuario().getTcc().get(0);
        } else
            if(!getUsuario().isAtivo())
                redirectHome();
            else
            {
                tcc = new TCC();
                tcc.setAluno(new Usuario());
                tcc.setProjeto(true);
                if (getUsuario().getCurso() != null)
                    tcc.getAluno().setCurso(getUsuario().getCurso());
                tcc.setAluno(getUsuario());
            }

        canChangeOrientacao = true;

        break;

    case Usuario.ADMINISTRADOR:
    case Usuario.COORDENADOR:
        canChangeMatricula = true;

    case Usuario.SECRETARIA:
        canEditUser = true;

    default:
        if (tccId != null && tccId.trim().length() > 0) {
            tcc = tccBusiness.getTCCById(Integer.parseInt(tccId.trim()));
        } else if (canEditUser) {
            tcc = new TCC();
            tcc.setAluno(new Usuario());
            if (getUsuario().getCurso() != null)
                tcc.getAluno().setCurso(getUsuario().getCurso());
            canChangeMatricula = true;
        }

        if (tcc == null || !canEdit())
            redirectHome();

    }
    if(tcc!=null)
    {
        hasCoOrientador = (tcc.getCoOrientador() != null);
        hasSubtitulo = (tcc.getSubNomeTCC() != null);
    }
    departamentos = (new DepartamentoBusiness()).getAll();
}