fixed damaged deleting slots, see #5
This commit is contained in:
@ -42,7 +42,7 @@ public abstract class CommonController {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ModelAttribute("hasDateRole")
|
||||
public Boolean hasDateRole(Principal principal) {
|
||||
OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) principal;
|
||||
@ -56,6 +56,21 @@ public abstract class CommonController {
|
||||
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
|
||||
*
|
||||
|
@ -23,10 +23,10 @@ import de.jottyfan.bico.db.tables.records.TLessonRecord;
|
||||
import de.jottyfan.bico.db.tables.records.TPersonRecord;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@Repository
|
||||
public class LessonRepository {
|
||||
private final static Logger LOGGER = LogManager.getLogger(LessonRepository.class);
|
||||
|
@ -25,7 +25,7 @@ public class ProfileController extends CommonController {
|
||||
* @param theme the theme
|
||||
*/
|
||||
@PostMapping("/updateTheme/{theme}")
|
||||
public ResponseEntity<?> updateTheme(@PathVariable String theme) {
|
||||
public ResponseEntity<?> updateTheme(@PathVariable("theme") String theme) {
|
||||
// TODO: add profile's user name
|
||||
String username = "jotty";
|
||||
service.updateTheme(username, theme);
|
||||
|
@ -30,20 +30,20 @@ public class SlotController extends CommonController {
|
||||
}
|
||||
|
||||
@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("hasLesson", service.slotHasLesson(id));
|
||||
return "/slot/item";
|
||||
}
|
||||
|
||||
@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));
|
||||
return "/slot/delete";
|
||||
}
|
||||
|
||||
@GetMapping("/slot/{id}/destroy")
|
||||
public String destroy(@PathVariable Integer id, Model model) {
|
||||
public String destroy(@PathVariable("id") Integer id, Model model) {
|
||||
service.removeSlot(id);
|
||||
return "redirect:/";
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class SlotRepository {
|
||||
.selectFrom(T_LESSON)
|
||||
.where(T_LESSON.FK_SLOT.eq(slotId));
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
LOGGER.info(sql);
|
||||
return sql.fetch().size() > 0;
|
||||
}
|
||||
}
|
||||
|
@ -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.authorization-grant-type = authorization_code
|
||||
spring.security.oauth2.client.registration.nextcloud.redirect-uri = ${nextcloud.redirect-uri}
|
||||
spring.security.oauth2.client.registration.nextcloud.client-authentication-method = client_secret_post
|
||||
|
@ -30,7 +30,8 @@
|
||||
<div class="col-sm-9">
|
||||
<button type="submit" class="btn btn-outline-success">Speichern</button>
|
||||
<a th:href="@{/}" class="btn btn-outline-secondary">Abbrechen</a>
|
||||
<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>
|
||||
</form>
|
||||
|
@ -14,7 +14,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<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
|
||||
class="bi bi-pencil" th:if="${s.abbreviation == null || s.abbreviation.isBlank()}"></i>
|
||||
</a></td>
|
||||
@ -32,8 +32,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td><a th:href="@{/slot/{id}(id=${s.pkSlot})}" class="btn btn-outline-secondary rightaligned"><i class="bi bi-pencil"></i></a>
|
||||
<span th:text="${s.slotNotes}" class="rightpadding64"></span></td>
|
||||
<td><span th:text="${s.slotNotes}" class="rightpadding64"></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<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="@{/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>
|
||||
@ -47,8 +47,8 @@
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<div layout:fragment="content" th:if="${hasBUrole || hasDateRole}">content</div>
|
||||
<div th:unless="${hasBUrole || hasDateRole}">
|
||||
<div layout:fragment="content" th:if="${hasAnyRole}">content</div>
|
||||
<div th:unless="${hasAnyRole}">
|
||||
<div class="borderdist">
|
||||
<div class="alert alert-danger">Leider fehlen Ihnen die Berechtigungen, um diese Anwendung nutzen zu können.</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user