Skip to content
Snippets Groups Projects
Commit 30fcc2d6 authored by Ruben Backx's avatar Ruben Backx :coffee:
Browse files

Merge branch 'dev' into 'master'

Add all programmes to admin coordinator page

See merge request !284
parents 13ac11d6 5d3c01c4
No related branches found
No related tags found
No related merge requests found
Pipeline #895390 passed with warnings
......@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
### Changed
### Fixed
## [2.1.3]
### Added
- Admins and programme coordinators can now add or remove TA coordinators. @rwbackx
......
......@@ -4,7 +4,7 @@ import nl.javadude.gradle.plugins.license.DownloadLicensesExtension
import nl.javadude.gradle.plugins.license.LicenseExtension
group = "nl.tudelft.tam"
version = "2.1.2"
version = "2.1.3"
val javaVersion = JavaVersion.VERSION_17
......
......@@ -32,6 +32,7 @@ import nl.tudelft.labracore.lib.security.user.Person;
import nl.tudelft.tam.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
......@@ -46,6 +47,7 @@ public class AuthorisationService {
private JobOfferService jobOfferService;
@Autowired
@Lazy
private ApplicationService applicationService;
@Autowired
......
......@@ -22,7 +22,9 @@ import java.util.List;
import nl.tudelft.labracore.api.ProgramControllerApi;
import nl.tudelft.labracore.api.dto.ProgramDetailsDTO;
import nl.tudelft.labracore.api.dto.ProgramSummaryDTO;
import nl.tudelft.labracore.lib.security.user.DefaultRole;
import nl.tudelft.tam.repository.CoordinatorRepository;
import nl.tudelft.tam.security.AuthorisationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -36,6 +38,9 @@ public class ProgramService {
@Autowired
private CoordinatorRepository coordinatorRepository;
@Autowired
private AuthorisationService authorisationService;
/**
* Get a program by id
*
......@@ -68,7 +73,11 @@ public class ProgramService {
* @return All program details coordinated
*/
public List<ProgramDetailsDTO> getCoordinatingPrograms(Long coordinatorId) {
return coordinatorRepository.findAllByPersonId(coordinatorId).stream()
return authorisationService.getAuthPerson().getDefaultRole() == DefaultRole.ADMIN
? programApi.getAllProgramsById(
programApi.getAllPrograms().map(ProgramSummaryDTO::getId).collectList().block())
.collectList().block()
: coordinatorRepository.findAllByPersonId(coordinatorId).stream()
.map(c -> programApi.getProgramById(c.getProgramId()).block()).toList();
}
......
......@@ -28,6 +28,8 @@ import java.util.List;
import nl.tudelft.labracore.api.ProgramControllerApi;
import nl.tudelft.labracore.api.dto.*;
import nl.tudelft.labracore.lib.security.user.DefaultRole;
import nl.tudelft.labracore.lib.security.user.Person;
import nl.tudelft.tam.cache.EditionCacheManager;
import nl.tudelft.tam.cache.PersonCacheManager;
import nl.tudelft.tam.dto.create.ApplicationCreateDTO;
......@@ -157,6 +159,8 @@ class ApplicationControllerTest {
@WithUserDetails("teacher")
void getAllApplicationsTest() throws Exception {
when(authService.isCoordinatorOfAny()).thenReturn(true);
when(authService.getAuthPerson())
.thenReturn(Person.builder().defaultRole(DefaultRole.TEACHER).build());
List<Application> appListStart = List.of(mapper.map(app1a, Application.class),
mapper.map(app3a, Application.class));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment