@ -3,6 +3,7 @@ package mops.gruppen2.controller;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.Role;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.Visibility;
|
||||
import mops.gruppen2.domain.exception.EventException;
|
||||
import mops.gruppen2.domain.exception.PageNotFoundException;
|
||||
import mops.gruppen2.security.Account;
|
||||
@ -271,8 +272,7 @@ public class WebController {
|
||||
|
||||
//TODO: Muss post-mapping sein
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||
@PostMapping("/acceptinvite/{link}")
|
||||
@CacheEvict(value = "groups", allEntries = true)
|
||||
@GetMapping("/acceptinvite/{link}")
|
||||
public String acceptInvite(KeycloakAuthenticationToken token,
|
||||
Model model,
|
||||
@PathVariable("link") String link) throws EventException {
|
||||
@ -281,9 +281,24 @@ public class WebController {
|
||||
validationService.checkGroup(group.getTitle());
|
||||
model.addAttribute("group", group);
|
||||
|
||||
controllerService.addUser(keyCloakService.createAccountFromPrincipal(token), group.getId());
|
||||
//controllerService.addUser(keyCloakService.createAccountFromPrincipal(token), group.getId());
|
||||
|
||||
return "redirect:/gruppen2/details/" + group.getId();
|
||||
if (group.getVisibility() == Visibility.PUBLIC) {
|
||||
return "redirect:/gruppen2/details/" + group.getId();
|
||||
}
|
||||
|
||||
return "joinprivate";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||
@PostMapping("/acceptinvite")
|
||||
@CacheEvict(value = "groups", allEntries = true)
|
||||
public String postAcceptInvite(KeycloakAuthenticationToken token,
|
||||
@RequestParam("id") String groupId) {
|
||||
|
||||
controllerService.addUser(keyCloakService.createAccountFromPrincipal(token), UUID.fromString(groupId));
|
||||
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||
|
81
src/main/resources/templates/joinprivate.html
Normal file
81
src/main/resources/templates/joinprivate.html
Normal file
@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Gruppendetails</title>
|
||||
<th:block th:fragment="headcontent">
|
||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||
</th:block>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation"
|
||||
th:switch="${account.getRoles().contains('orga')}">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
||||
</li>
|
||||
<li th:case="${true}">
|
||||
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
|
||||
</li>
|
||||
<li th:case="${false}">
|
||||
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
|
||||
</li>
|
||||
<li class="active">
|
||||
<a href="/findGroup" th:href="@{/gruppen2/findGroup}">Suche</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<main th:fragment="bodycontent">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-9">
|
||||
<div class="shadow-sm p-4"
|
||||
style="border: 1px solid aliceblue; border-radius: 5px; background: aliceblue">
|
||||
<h1 style="color: black; font-weight: bold; font-optical-sizing: auto; overflow-wrap: break-word"
|
||||
th:text="${group.getTitle()}"></h1>
|
||||
<h3>Möchtest du dieser privaten Gruppe beitreten?</h3>
|
||||
<div class="shadow-sm p-4" style="background: white">
|
||||
<p style="overflow-wrap: break-word; font-optical-sizing: auto"
|
||||
th:text="${group.getDescription()}"></p>
|
||||
</div>
|
||||
<div class="form-group mt-2">
|
||||
<div class="text-right">
|
||||
<form method="post" th:action="@{/gruppen2/acceptinvite}">
|
||||
<input name="id" th:value="${group.getId()}" type="hidden"/>
|
||||
<button class="btn btn-primary"
|
||||
style="background: #52a1eb; border-style: none;"
|
||||
type="submit">Ja, Gruppe beitreten
|
||||
</button>
|
||||
<a class="btn btn-primary"
|
||||
href="/gruppen2"
|
||||
style="background: #52a1eb; border-style: none;"
|
||||
type="submit">Ich will das nicht.
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3" style="white-space: nowrap">
|
||||
<div style="display: inline-block; margin: 0">
|
||||
<h2>Mitglieder</h2>
|
||||
<div th:switch="${group.getUserMaximum() != 100000}">
|
||||
<h4 th:case="${true}">
|
||||
<a th:text="${group.getMembers().size()}"></a>
|
||||
<a>von maximal</a>
|
||||
<a th:text="${group.getUserMaximum()}"></a>
|
||||
<a>Benutzern.</a>
|
||||
</h4>
|
||||
<h4 th:case="false">unbegrenzte Teilnehmeranzahl</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user