fixed damaged deleting slots, see #5

This commit is contained in:
Jottyfan
2024-11-11 23:03:21 +01:00
parent a1ad23920a
commit bf88306d85
12 changed files with 59 additions and 25 deletions

View File

@ -12,6 +12,13 @@
<attribute name="gradle_used_by_scope" value="main,test"/> <attribute name="gradle_used_by_scope" value="main,test"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"> <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">

View File

@ -1,8 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="BiCO"> <wb-module deploy-name="BiCO">
<property name="context-root" value="BiCO"/> <property name="context-root" value="BiCO"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
</wb-module> </wb-module>
</project-modules> </project-modules>

View File

@ -8,7 +8,7 @@ plugins {
} }
group = 'de.jottyfan.bico' group = 'de.jottyfan.bico'
version = '0.1.4' version = '0.1.5'
description = """BibleClassOrganizer""" description = """BibleClassOrganizer"""
@ -83,3 +83,8 @@ test {
springBoot { springBoot {
buildInfo() buildInfo()
} }
tasks.withType(JavaCompile).configureEach {
options.compilerArgs.add("-parameters")
}

View File

@ -56,6 +56,21 @@ public abstract class CommonController {
return false; return false;
} }
} }
@ModelAttribute("hasAnyRole")
public Boolean hasAnyRole(Principal principal) {
OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) principal;
if (token != null) {
OAuth2User user = token.getPrincipal();
@SuppressWarnings("unchecked")
List<String> roles = (List<String>) user.getAttributes().get("roles");
return roles.size() > 0;
} else {
LOGGER.warn("token is null, no roles can be detected");
return false;
}
}
/** /**
* get the theme for the current session * get the theme for the current session
* *

View File

@ -25,7 +25,7 @@ public class ProfileController extends CommonController {
* @param theme the theme * @param theme the theme
*/ */
@PostMapping("/updateTheme/{theme}") @PostMapping("/updateTheme/{theme}")
public ResponseEntity<?> updateTheme(@PathVariable String theme) { public ResponseEntity<?> updateTheme(@PathVariable("theme") String theme) {
// TODO: add profile's user name // TODO: add profile's user name
String username = "jotty"; String username = "jotty";
service.updateTheme(username, theme); service.updateTheme(username, theme);

View File

@ -30,20 +30,20 @@ public class SlotController extends CommonController {
} }
@GetMapping("/slot/{id}") @GetMapping("/slot/{id}")
public String load(@PathVariable Integer id, Model model) { public String load(@PathVariable("id") Integer id, Model model) {
model.addAttribute("bean", id == null ? new SlotBean() : service.loadSlot(id)); model.addAttribute("bean", id == null ? new SlotBean() : service.loadSlot(id));
model.addAttribute("hasLesson", service.slotHasLesson(id)); model.addAttribute("hasLesson", service.slotHasLesson(id));
return "/slot/item"; return "/slot/item";
} }
@GetMapping("/slot/{id}/delete") @GetMapping("/slot/{id}/delete")
public String loadEnsurance(@PathVariable Integer id, Model model) { public String loadEnsurance(@PathVariable("id") Integer id, Model model) {
model.addAttribute("bean", service.loadDeletableSlot(id)); model.addAttribute("bean", service.loadDeletableSlot(id));
return "/slot/delete"; return "/slot/delete";
} }
@GetMapping("/slot/{id}/destroy") @GetMapping("/slot/{id}/destroy")
public String destroy(@PathVariable Integer id, Model model) { public String destroy(@PathVariable("id") Integer id, Model model) {
service.removeSlot(id); service.removeSlot(id);
return "redirect:/"; return "redirect:/";
} }

View File

@ -139,7 +139,7 @@ public class SlotRepository {
.selectFrom(T_LESSON) .selectFrom(T_LESSON)
.where(T_LESSON.FK_SLOT.eq(slotId)); .where(T_LESSON.FK_SLOT.eq(slotId));
// @formatter:on // @formatter:on
LOGGER.trace(sql); LOGGER.info(sql);
return sql.fetch().size() > 0; return sql.fetch().size() > 0;
} }
} }

View File

@ -15,3 +15,4 @@ spring.security.oauth2.client.registration.nextcloud.client-id = ${nextcloud.cli
spring.security.oauth2.client.registration.nextcloud.client-secret = ${nextcloud.client-secret} spring.security.oauth2.client.registration.nextcloud.client-secret = ${nextcloud.client-secret}
spring.security.oauth2.client.registration.nextcloud.authorization-grant-type = authorization_code spring.security.oauth2.client.registration.nextcloud.authorization-grant-type = authorization_code
spring.security.oauth2.client.registration.nextcloud.redirect-uri = ${nextcloud.redirect-uri} spring.security.oauth2.client.registration.nextcloud.redirect-uri = ${nextcloud.redirect-uri}
spring.security.oauth2.client.registration.nextcloud.client-authentication-method = client_secret_post

View File

@ -30,7 +30,8 @@
<div class="col-sm-9"> <div class="col-sm-9">
<button type="submit" class="btn btn-outline-success">Speichern</button>&nbsp; <button type="submit" class="btn btn-outline-success">Speichern</button>&nbsp;
<a th:href="@{/}" class="btn btn-outline-secondary">Abbrechen</a>&nbsp; <a th:href="@{/}" class="btn btn-outline-secondary">Abbrechen</a>&nbsp;
<a th:href="@{/lesson/{id}/remove(id=${bean.pkLesson})}" class="btn btn-outline-danger">Löschen</a> <a th:href="@{/lesson/{id}/remove(id=${bean.pkLesson})}" class="btn btn-outline-danger">Zuordnung löschen</a>
<a th:href="@{/slot/{id}(id=${bean.fkSlot})}" class="btn btn-outline-warning">Termin bearbeiten</a>
</div> </div>
</div> </div>
</form> </form>

View File

@ -14,7 +14,7 @@
</thead> </thead>
<tbody> <tbody>
<tr th:each="s : ${list}"> <tr th:each="s : ${list}">
<td th:data-sort="${#temporals.format(s.slotDay, 'yyyy-MM-dd')}"><span th:text="${#temporals.format(s.slotDay, 'dd.MM.yyyy')}"></span></td> <td th:data-sort="${#temporals.format(s.slotDay, 'yyyy-MM-dd')}"><a th:href="@{/slot/{id}(id=${s.pkSlot})}" th:text="${#temporals.format(s.slotDay, 'dd.MM.yyyy')}"></a></td>
<td><a th:href="@{/lesson?slotId={id}(id=${s.pkSlot})}" class="btn btn-outline-secondary"> <span th:text="${s.abbreviation}" th:if="${s.abbreviation}"></span> <i <td><a th:href="@{/lesson?slotId={id}(id=${s.pkSlot})}" class="btn btn-outline-secondary"> <span th:text="${s.abbreviation}" th:if="${s.abbreviation}"></span> <i
class="bi bi-pencil" th:if="${s.abbreviation == null || s.abbreviation.isBlank()}"></i> class="bi bi-pencil" th:if="${s.abbreviation == null || s.abbreviation.isBlank()}"></i>
</a></td> </a></td>
@ -32,8 +32,7 @@
</div> </div>
</div> </div>
</td> </td>
<td><a th:href="@{/slot/{id}(id=${s.pkSlot})}" class="btn btn-outline-secondary rightaligned"><i class="bi bi-pencil"></i></a> <td><span th:text="${s.slotNotes}" class="rightpadding64"></span></td>
<span th:text="${s.slotNotes}" class="rightpadding64"></span></td>
</tr> </tr>
</tbody> </tbody>
<tfoot> <tfoot>

View File

@ -24,7 +24,7 @@
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarSupportedContent" style="margin-right: 20px"> <div class="collapse navbar-collapse" id="navbarSupportedContent" style="margin-right: 20px">
<ul class="navbar-nav mb-2 mb-lg-0" th:if="${hasBUrole || hasDateRole}"> <ul class="navbar-nav mb-2 mb-lg-0" th:if="${hasAnyRole}">
<li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/next}" style="margin-left: 12px">Dienstplan</a></li> <li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/next}" style="margin-left: 12px">Dienstplan</a></li>
<li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/sheet}" style="margin-left: 12px" th:if="${hasBUrole}">Einteilung</a></li> <li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/sheet}" style="margin-left: 12px" th:if="${hasBUrole}">Einteilung</a></li>
<li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/subject/list}" style="margin-left: 12px" th:if="${hasBUrole}">Themen</a></li> <li class="nav-item"><a class="btn btn-outline-secondary" th:href="@{/subject/list}" style="margin-left: 12px" th:if="${hasBUrole}">Themen</a></li>
@ -47,8 +47,8 @@
</ul> </ul>
</div> </div>
</nav> </nav>
<div layout:fragment="content" th:if="${hasBUrole || hasDateRole}">content</div> <div layout:fragment="content" th:if="${hasAnyRole}">content</div>
<div th:unless="${hasBUrole || hasDateRole}"> <div th:unless="${hasAnyRole}">
<div class="borderdist"> <div class="borderdist">
<div class="alert alert-danger">Leider fehlen Ihnen die Berechtigungen, um diese Anwendung nutzen zu können.</div> <div class="alert alert-danger">Leider fehlen Ihnen die Berechtigungen, um diese Anwendung nutzen zu können.</div>
</div> </div>