diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c96410ac7dd0131b8442abcad34ca0b8f0d50bc..f1c85aceaa053be2a80d109bc2a272bf2263dbb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Written feedback sorting now follows a reverse chronological order. [@hpage](https://gitlab.ewi.tudelft.nl/hpage) +- Users will see a dialog instead of a new page when promopted to unenrol from an edition. [@hpage](https://gitlab.ewi.tudelft.nl/hpage) + - Text used to indicate the number of times a lab is rescheduled is now more intuitive. [@hpage](https://gitlab.ewi.tudelft.nl/hpage) - Assistants who couldn't locate students are no longer eligible to receive feedback from those students. [@hpage](https://gitlab.ewi.tudelft.nl/hpage) @@ -26,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The request history page can now be seen for participants. [@mmadara](https://gitlab.ewi.tudelft.nl/mmadara) - Teachers can now view their own feedback again. [@hpage](https://gitlab.ewi.tudelft.nl/hpage) - The feedback graph for assistants now incorporates feedback from other courses, with written feedback limited to visibility for course managers. [@hpage](https://gitlab.ewi.tudelft.nl/hpage) +- The button that lets users unenrol from an edition now disabled when appropriate. [@hpage](https://gitlab.ewi.tudelft.nl/hpage) +### Fixed - The assignment count graph on the edition statistic page was fixed. [@hpage](https://gitlab.ewi.tudelft.nl/hpage) - Limited capacity sessions were not shown on the home page [@rwbackx](https://gitlab.ewi.tudelft.nl/rwbackx) - Limited capacity sessions can now have extra information. [@hpage](https://gitlab.ewi.tudelft.nl/hpage) diff --git a/src/main/java/nl/tudelft/queue/controller/EditionController.java b/src/main/java/nl/tudelft/queue/controller/EditionController.java index ff7419e2f23fcba383febc96562e228647b3d7a6..f1ac03002b4c7d4be3f40e6f0199cd67de34a3c1 100644 --- a/src/main/java/nl/tudelft/queue/controller/EditionController.java +++ b/src/main/java/nl/tudelft/queue/controller/EditionController.java @@ -611,27 +611,6 @@ public class EditionController { return "redirect:/edition/" + editionId + "/participants"; } - /** - * Gets the page to confirm for a student that they want to unenrol from the given course edition. - * - * @param editionId The id of the edition from which a student wants to unenrol. - * @param model The model to fill out for Thymeleaf template resolution. - * @return The Thymeleaf template to resolve. - */ - @GetMapping("/edition/{editionId}/leave") - @PreAuthorize("@permissionService.canLeaveEdition(#editionId)") - public String getParticipantLeavePage(@PathVariable Long editionId, - Model model) { - EditionDetailsDTO edition = eCache.getRequired(editionId); - model.addAttribute("edition", es.queueEditionDTO(edition, QueueEditionDetailsDTO.class)); - model.addAttribute("assignments", - mCache.getAndIgnoreMissing(edition.getModules().stream().map(ModuleSummaryDTO::getId)) - .stream() - .flatMap(m -> m.getAssignments().stream()).toList()); - - return "edition/view/leave"; - } - /** * Processes a POST request from the user wanting to leave the given edition. Instead of deleting the role * of the user from the database entirely, we opt to block their role and thus disallow them access to the diff --git a/src/main/java/nl/tudelft/queue/service/RoleDTOService.java b/src/main/java/nl/tudelft/queue/service/RoleDTOService.java index 2be5d8a9f17ab96a13cad6302cf79566370684e4..e3fa8a88effebb8009fc8f66ed324e937ade8251 100644 --- a/src/main/java/nl/tudelft/queue/service/RoleDTOService.java +++ b/src/main/java/nl/tudelft/queue/service/RoleDTOService.java @@ -33,7 +33,6 @@ import nl.tudelft.labracore.api.dto.*; import nl.tudelft.labracore.lib.security.user.Person; import nl.tudelft.queue.cache.EditionCacheManager; import nl.tudelft.queue.cache.EditionRolesCacheManager; -import nl.tudelft.queue.cache.SessionCacheManager; import nl.tudelft.queue.model.QueueSession; @Service @@ -46,8 +45,6 @@ public class RoleDTOService { private EditionCacheManager eCache; - private SessionCacheManager sessionCacheManager; - public List<String> names(List<PersonSummaryDTO> people) { return people.stream().map(PersonSummaryDTO::getDisplayName).collect(Collectors.toList()); } diff --git a/src/main/resources/templates/edition/view.html b/src/main/resources/templates/edition/view.html index 6ea362b85c67576106aa70384bc9079378b6f16a..b528a5330607a809ab2023ae96473569e093ba46 100644 --- a/src/main/resources/templates/edition/view.html +++ b/src/main/resources/templates/edition/view.html @@ -76,15 +76,16 @@ <a th:href="@{/edition/{id}/enrol(id=${edition.id})}" th:if="${@permissionService.canEnrolForEdition(edition.id)}" class="button"> Enrol for this edition </a> - <a - th:href="@{/edition/{id}/leave(id=${edition.id})}" + + <button th:if="${@permissionService.canViewEdition(edition.id)}" - th:disabled="not ${@permissionService.canLeaveEdition(edition.id)}" class="button" - data-style="outlined" - data-type="error"> + data-type="error" + th:attrappend="data-style=${@permissionService.canLeaveEdition(edition.id)}?outlined" + th:disabled="not ${@permissionService.canLeaveEdition(edition.id)}" + th:data-dialog="leave-edition-dialog"> Leave edition - </a> + </button> </div> </div> @@ -145,6 +146,26 @@ </button> </div> + <dialog + class="dialog" + id="leave-edition-dialog" + th:if="${ec == null and @permissionService.canViewEdition(edition.id)} and ${@permissionService.canLeaveEdition(edition.id)}"> + <form th:action="@{/edition/{id}/leave(id=${edition.id})}" method="post" class="flex vertical p-7"> + <h3 class="underlined font-500">Leave Edition</h3> + + <p> + Are you sure you want to leave the edition + <strong class="fw-500" th:text="|${edition.course.name} - ${edition.name}|"></strong> + ? + </p> + + <div class="flex space-between"> + <button type="button" data-cancel class="button p-less" data-style="outlined">Cancel</button> + <button type="submit" class="button p-less" data-type="error">Leave Edition</button> + </div> + </form> + </dialog> + <div layout:fragment="subcontent">Sub content page</div> </main> </body> diff --git a/src/main/resources/templates/edition/view/leave.html b/src/main/resources/templates/edition/view/leave.html deleted file mode 100644 index dd24c395e7e6c50ff26e384252d96b1af3efb36e..0000000000000000000000000000000000000000 --- a/src/main/resources/templates/edition/view/leave.html +++ /dev/null @@ -1,47 +0,0 @@ -<!-- - - Queue - A Queueing system that can be used to handle labs in higher education - Copyright (C) 2016-2020 Delft University of Technology - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - ---> -<!DOCTYPE html> -<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{edition/view}"> - <!--@thymesVar id="edition" type="nl.tudelft.labracore.api.dto.EditionDetailsDTO"--> - - <head> - <title th:text="|Leave - ${edition.course.name} (${edition.name})|"></title> - </head> - - <body> - <section layout:fragment="subcontent"> - <h3 class="font-500 mb-5">Leave edition</h3> - - <p class="mb-5"> - Are you sure you want to leave the edition - <strong th:text="|${edition.course.name} - ${edition.name}|"></strong> - ? - </p> - - <form th:action="@{/edition/{id}/leave(id=${edition.id})}" method="post"> - <button type="submit" class="button" data-type="error">Leave</button> - <span> - or - <a class="link" th:href="@{/edition/{id}(id=${edition.id})}">go back</a> - </span> - </form> - </section> - </body> -</html> diff --git a/src/test/java/nl/tudelft/queue/service/RoleDTOServiceTest.java b/src/test/java/nl/tudelft/queue/service/RoleDTOServiceTest.java index eb0a1de98f8514515ff6e7386198bb46d42a4bab..4c6a72d481749af0e3e1d283d4eb63f3aaa05e2c 100644 --- a/src/test/java/nl/tudelft/queue/service/RoleDTOServiceTest.java +++ b/src/test/java/nl/tudelft/queue/service/RoleDTOServiceTest.java @@ -34,7 +34,6 @@ import nl.tudelft.labracore.lib.security.user.DefaultRole; import nl.tudelft.labracore.lib.security.user.Person; import nl.tudelft.queue.cache.EditionCacheManager; import nl.tudelft.queue.cache.EditionRolesCacheManager; -import nl.tudelft.queue.cache.SessionCacheManager; import reactor.core.publisher.Flux; public class RoleDTOServiceTest { @@ -43,8 +42,6 @@ public class RoleDTOServiceTest { private EditionCacheManager cacheManager; - private SessionCacheManager sessionCacheManager; - private final ModelMapper mapper = new ModelMapper(); private final RoleControllerApi roleControllerApi; @@ -69,10 +66,8 @@ public class RoleDTOServiceTest { public RoleDTOServiceTest() { this.eCache = mock(EditionRolesCacheManager.class); this.cacheManager = mock(EditionCacheManager.class); - this.sessionCacheManager = mock(SessionCacheManager.class); this.roleControllerApi = mock(RoleControllerApi.class); - this.roleDTOService = new RoleDTOService(eCache, roleControllerApi, cacheManager, - sessionCacheManager); + this.roleDTOService = new RoleDTOService(eCache, roleControllerApi, cacheManager); } @BeforeEach