3214 Fix crash when students unselects a supervisor idea and presses the back button in the browser

This commit is contained in:
Andreas Svanberg 2023-10-30 15:12:51 +01:00
parent 30984192bb
commit 58d95df913
2 changed files with 7 additions and 1 deletions
core/src/main/java/se/su/dsv/scipro/match
view/src/main/java/se/su/dsv/scipro/match

@ -554,6 +554,12 @@ public class IdeaServiceImpl extends AbstractServiceImpl<Idea, Long> implements
@Override
public boolean canEdit(final Idea idea, final User student) {
boolean isAuthor = idea.getIdeaParticipations()
.stream()
.anyMatch(ip -> Objects.equals(student, ip.getUser()));
if (!isAuthor) {
return false;
}
final ApplicationPeriod applicationPeriod = idea.getApplicationPeriod();
return applicationPeriodService.isOpen(applicationPeriod)
|| (idea.getType() == Type.STUDENT && applicationPeriodService.hasCurrentSubmitIdeaExemption(applicationPeriod, student))

@ -33,7 +33,7 @@ public class ProjectIdeaDetailsPage extends AbstractIdeaProjectPage implements M
.stream()
.anyMatch(ideaParticipation -> ideaParticipation.getUser().equals(loggedInUser()));
if (!isAuthor) {
throw new RestartResponseException(getApplication().getHomePage());
throw new RestartResponseException(ProjectIdeaStartPage.class);
}
final DetachableServiceModel<Idea> ideaModel = new DetachableServiceModel<>(ideaService, idea);