latest project now made active upon login

This commit is contained in:
Fredrik Friis 2012-02-10 13:54:09 +09:00
parent 6137c285c5
commit 636b28acca

@ -32,7 +32,15 @@ public abstract class ProjectPage extends MenuPage implements FilePanelContainer
if(activeProject == null && (this.getClass() != NoActiveProjectPage.class && this.getClass() != ProjectPartnerPage.class && this.getClass() != ProjectIdeaPage.class && this.getClass() != ProjectIdeaSubmissionPage.class)){
User user = SciProSession.get().getUser();
List<Project> activeProjects = projectDao.getProjectsByParticipant(user, null );
if(activeProjects.size() == 1){ //If user has only one project, set it as default, otherwise let him choose
//if the user has more than one project, activate the latest one (last one in the list of projects)
if(activeProjects.size() > 1){
activeProject = activeProjects.get(activeProjects.size()-1);
SciProSession.get().setActiveProject(activeProject);
UserSettings userSettings = userSettingsDao.getUserSettings(user);
userSettings.setActiveProject(activeProject);
userSettings = userSettingsDao.save(userSettings);
}
else if(activeProjects.size() == 1){ //If user has only one project, set it as default, otherwise let him choose
activeProject = activeProjects.get(0);
SciProSession.get().setActiveProject(activeProject);
UserSettings userSettings = userSettingsDao.getUserSettings(user);