3214 Fix crash when students unselects a supervisor idea and presses the back button in the browser
This commit is contained in:
parent
30984192bb
commit
58d95df913
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user