Fix merge with master
This commit is contained in:
@ -16,7 +16,6 @@ import mops.gruppen2.service.GroupService;
|
|||||||
import mops.gruppen2.service.InviteLinkRepositoryService;
|
import mops.gruppen2.service.InviteLinkRepositoryService;
|
||||||
import mops.gruppen2.service.KeyCloakService;
|
import mops.gruppen2.service.KeyCloakService;
|
||||||
import mops.gruppen2.service.UserService;
|
import mops.gruppen2.service.UserService;
|
||||||
import org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException;
|
|
||||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
@ -28,7 +27,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.context.annotation.SessionScope;
|
import org.springframework.web.context.annotation.SessionScope;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
import java.io.CharConversionException;
|
import java.io.CharConversionException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -84,11 +82,12 @@ public class Gruppen2Controller {
|
|||||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
||||||
@PostMapping("/createOrga")
|
@PostMapping("/createOrga")
|
||||||
public String pCreateOrga(KeycloakAuthenticationToken token,
|
public String pCreateOrga(KeycloakAuthenticationToken token,
|
||||||
@RequestParam("title") String title,
|
@RequestParam("title") String title,
|
||||||
@RequestParam("beschreibung") String beschreibung,
|
@RequestParam("description") String description,
|
||||||
@RequestParam(value = "visibility", required = false) Boolean visibility,
|
@RequestParam(value = "visibility", required = false) Boolean visibility,
|
||||||
@RequestParam(value = "lecture", required = false) Boolean lecture,
|
@RequestParam(value = "lecture", required = false) Boolean lecture,
|
||||||
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException {
|
@RequestParam("userMaximum") Long userMaximum,
|
||||||
|
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException {
|
||||||
|
|
||||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||||
List<User> userList = new ArrayList<>();
|
List<User> userList = new ArrayList<>();
|
||||||
@ -102,7 +101,7 @@ public class Gruppen2Controller {
|
|||||||
visibility = visibility == null;
|
visibility = visibility == null;
|
||||||
lecture = lecture == null;
|
lecture = lecture == null;
|
||||||
|
|
||||||
controllerService.createOrga(account, title, beschreibung, visibility, lecture, userList);
|
controllerService.createOrga(account, title, description, visibility, lecture, userMaximum, userList);
|
||||||
|
|
||||||
return "redirect:/gruppen2/";
|
return "redirect:/gruppen2/";
|
||||||
}
|
}
|
||||||
@ -117,13 +116,14 @@ public class Gruppen2Controller {
|
|||||||
@RolesAllowed({"ROLE_studentin"})
|
@RolesAllowed({"ROLE_studentin"})
|
||||||
@PostMapping("/createStudent")
|
@PostMapping("/createStudent")
|
||||||
public String pCreateStudent(KeycloakAuthenticationToken token,
|
public String pCreateStudent(KeycloakAuthenticationToken token,
|
||||||
@RequestParam("title") String title,
|
@RequestParam("title") String title,
|
||||||
@RequestParam("beschreibung") String beschreibung,
|
@RequestParam("description") String description,
|
||||||
@RequestParam(value = "visibility", required = false) Boolean visibility) throws EventException {
|
@RequestParam(value = "visibility", required = false) Boolean visibility,
|
||||||
|
@RequestParam("userMaximum") Long userMaximum) throws EventException {
|
||||||
|
|
||||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||||
visibility = visibility == null;
|
visibility = visibility == null;
|
||||||
controllerService.createGroup(account, title, beschreibung, visibility);
|
controllerService.createGroup(account, title, description, visibility, userMaximum);
|
||||||
|
|
||||||
return "redirect:/gruppen2/";
|
return "redirect:/gruppen2/";
|
||||||
}
|
}
|
||||||
@ -138,8 +138,6 @@ public class Gruppen2Controller {
|
|||||||
userList = CsvService.read(file.getInputStream());
|
userList = CsvService.read(file.getInputStream());
|
||||||
} catch (UnrecognizedPropertyException | CharConversionException ex) {
|
} catch (UnrecognizedPropertyException | CharConversionException ex) {
|
||||||
throw new WrongFileException(file.getOriginalFilename());
|
throw new WrongFileException(file.getOriginalFilename());
|
||||||
} catch (IllegalStateException ex) {
|
|
||||||
throw new WrongFileException(file.getOriginalFilename());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
controllerService.addUserList(userList, groupId);
|
controllerService.addUserList(userList, groupId);
|
||||||
@ -159,21 +157,6 @@ public class Gruppen2Controller {
|
|||||||
return "search";
|
return "search";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
|
||||||
@PostMapping("/createGroup")
|
|
||||||
public String pCreateGroup(KeycloakAuthenticationToken token,
|
|
||||||
@RequestParam("title") String title,
|
|
||||||
@RequestParam("description") String description,
|
|
||||||
@RequestParam(value = "visibility", required = false) Boolean visibility,
|
|
||||||
@RequestParam("userMaximum") Long userMaximum) throws EventException {
|
|
||||||
|
|
||||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
|
||||||
visibility = visibility == null;
|
|
||||||
controllerService.createGroup(account, title, description, visibility, userMaximum);
|
|
||||||
|
|
||||||
return "redirect:/gruppen2/";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||||
@GetMapping("/details/{id}")
|
@GetMapping("/details/{id}")
|
||||||
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable("id") Long groupId) throws EventException {
|
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable("id") Long groupId) throws EventException {
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public class ControllerService {
|
|||||||
updateRole(account.getName(), groupId);
|
updateRole(account.getName(), groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createOrga(Account account, String title, String description, Boolean visibility, Boolean lecture, List<User> users) throws EventException {
|
public void createOrga(Account account, String title, String description, Boolean visibility, Boolean lecture, Long maximmum, List<User> users) throws EventException {
|
||||||
Visibility visibility1;
|
Visibility visibility1;
|
||||||
Long groupId = eventService.checkGroup();
|
Long groupId = eventService.checkGroup();
|
||||||
|
|
||||||
@ -82,7 +82,8 @@ public class ControllerService {
|
|||||||
} else {
|
} else {
|
||||||
groupType = GroupType.LECTURE;
|
groupType = GroupType.LECTURE;
|
||||||
}
|
}
|
||||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), null, groupType, visibility1);
|
|
||||||
|
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), null, groupType, visibility1, maximmum);
|
||||||
eventService.saveEvent(createGroupEvent);
|
eventService.saveEvent(createGroupEvent);
|
||||||
|
|
||||||
addUser(account, groupId);
|
addUser(account, groupId);
|
||||||
@ -163,26 +164,6 @@ public class ControllerService {
|
|||||||
eventService.saveEvent(deleteGroupEvent);
|
eventService.saveEvent(deleteGroupEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createLecture(Account account, String title, String description, Boolean visibility, List<User> users) throws EventException {
|
|
||||||
Visibility visibility1;
|
|
||||||
Long groupId = eventService.checkGroup();
|
|
||||||
|
|
||||||
if (visibility) {
|
|
||||||
visibility1 = Visibility.PUBLIC;
|
|
||||||
} else {
|
|
||||||
visibility1 = Visibility.PRIVATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), null, GroupType.LECTURE, visibility1, 1000L); //this has to be changed also Usermaximum
|
|
||||||
eventService.saveEvent(createGroupEvent);
|
|
||||||
|
|
||||||
addUser(account, groupId);
|
|
||||||
updateTitle(account, groupId, title);
|
|
||||||
updateDescription(account, groupId, description);
|
|
||||||
updateRole(account.getName(), groupId);
|
|
||||||
addUserList(users, groupId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean passIfLastAdmin(Account account, Long groupId){
|
public boolean passIfLastAdmin(Account account, Long groupId){
|
||||||
Group group = userService.getGroupById(groupId);
|
Group group = userService.getGroupById(groupId);
|
||||||
if (group.getMembers().size() <= 1){
|
if (group.getMembers().size() <= 1){
|
||||||
|
|||||||
@ -47,9 +47,14 @@
|
|||||||
type="text">
|
type="text">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="beschreibung">Beschreibung</label>
|
<label for="description">Beschreibung</label>
|
||||||
<textarea class="form-control" id="beschreibung" required
|
<textarea class="form-control" id="description" required
|
||||||
rows="3" th:name="beschreibung"></textarea>
|
rows="3" th:name="description"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-group mt-3">
|
||||||
|
<label for="userMaximum">Teilnehmeranzahl</label>
|
||||||
|
<input class="form-control" id="userMaximum" required th:name="userMaximum"
|
||||||
|
type="number" min="1">
|
||||||
</div>
|
</div>
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input class="custom-control-input" id="visibility" th:name="visibility"
|
<input class="custom-control-input" id="visibility" th:name="visibility"
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
<h1>Gruppenerstellung</h1>
|
<h1>Gruppenerstellung</h1>
|
||||||
<form method="post" action="/gruppen2/createGroup">
|
<form method="post" action="/gruppen2/createStudent">
|
||||||
<div class="shadow p-2" style=" border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
|
<div class="shadow p-2" style=" border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
Reference in New Issue
Block a user