Tours re s tiction works - tests needs to be done

This commit is contained in:
Filip Izydorczyk 2021-01-14 11:21:41 +01:00
parent 9c1a148e20
commit 334129cb70

View File

@ -22,7 +22,9 @@ import com.plannaplan.responses.mappers.CommisionResponseMappers;
import com.plannaplan.responses.models.CommisionResponse;
import com.plannaplan.services.AssignmentService;
import com.plannaplan.services.CommisionService;
import com.plannaplan.services.ConfiguratorService;
import com.plannaplan.services.GroupService;
import com.plannaplan.types.AppState;
import com.plannaplan.types.UserRoles;
import org.springframework.beans.factory.annotation.Autowired;
@ -56,6 +58,9 @@ public class CommisionController extends TokenBasedController {
@Autowired
private AssignmentService assignmentService;
@Autowired
private ConfiguratorService configuratorService;
public CommisionController() {
}
@ -66,7 +71,7 @@ public class CommisionController extends TokenBasedController {
@PathVariable(name = "id", required = false) Long userId) {
try {
final AppState appState = this.configuratorService.getCurrentConfig().getCurrentState();
final User asker = this.getCurrentUser()
.orElseThrow(() -> new UserNotFoundException("Invalid token"));
@ -76,7 +81,9 @@ public class CommisionController extends TokenBasedController {
: asker;
Assert.isTrue((asker.getRole() == UserRoles.DEANERY && user.getRole() == UserRoles.STUDENT
|| (asker.getId().equals(user.getId()) && user.getRole() == UserRoles.STUDENT)),
&& appState == AppState.NO_TOUR
|| (asker.getId().equals(user.getId()) && user.getRole() == UserRoles.STUDENT
&& appState != AppState.NO_TOUR)),
"Incorrect attempt to change plan");
Optional<Long> notExistingGroup = this.groupServcicxe.findNotExistingGroup(groups);