Skip to content
Snippets Groups Projects
Commit e5e73f5e authored by Otto Visser's avatar Otto Visser
Browse files

Merge branch '77-searching-for-course-code-does-not-find-course' into 'development'

Resolve "Searching for course code does not find course"

Closes #77

See merge request !77
parents 07d7971b 77134609
No related branches found
No related tags found
2 merge requests!81Minor fixes,!77Resolve "Searching for course code does not find course"
......@@ -141,12 +141,13 @@ public class EditionController {
.getEnrolledEditionsForPerson(new PersonIdDTO().id(person.getId()));
List<EditionDetailsDTO> editions = editionService
.getEditions(roles.stream().map(e -> e.getEdition().getId()).collect(Collectors.toList()));
Map<Long, String> courses = editions.stream()
.collect(Collectors.toMap(EditionDetailsDTO::getId, e -> e.getCourse().getName()));
Map<Long, CourseSummaryDTO> courses = editions.stream()
.collect(Collectors.toMap(EditionDetailsDTO::getId, e -> e.getCourse()));
if (q != null) {
roles = roles.stream()
.filter(r -> r.getEdition().getName().contains(q)
|| courses.get(r.getEdition().getId()).contains(q))
|| courses.get(r.getEdition().getId()).getName().contains(q)
|| courses.get(r.getEdition().getId()).getCode().contains(q))
.collect(Collectors.toList());
}
......
......@@ -48,8 +48,8 @@
<div class="editions">
<a th:each="role : ${roles}" th:href="@{|/edition/${role.edition.id}|}" class="interactive card edition">
<div class="edition_info">
<span class="edition_name" th:text="${role.edition.name}"></span>
<span class="edition_course" th:text="${courses[role.edition.id]}"></span>
<span class="edition_name" th:text="${courses[role.edition.id].name}"></span>
<span class="edition_course" th:text="${role.edition.name}"></span>
</div>
<span class="edition_role" th:text="${role.edition.isArchived} ? #{edition.archived} : #{|role.${#strings.toLowerCase(role.type.toString())}|}"></span>
......
......@@ -144,6 +144,7 @@ public class EditionControllerTest {
void getAllEnrolledEditions() throws Exception {
List<RoleEditionDetailsDTO> roles = List.of(ROLE_VIEW);
when(editionService.getEnrolledEditionsForPerson(any(PersonIdDTO.class))).thenReturn(roles);
when(editionService.getEditions(anyList())).thenReturn(List.of(EDITION_VIEW));
mockMvc.perform(get("/edition/enrolled"))
.andExpect(status().isOk())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment