1

Fix merge with master

This commit is contained in:
XXNitram
2020-03-19 17:24:10 +01:00
parent ef044cbdf7
commit b24f6d273f
4 changed files with 24 additions and 55 deletions

View File

@ -16,7 +16,6 @@ import mops.gruppen2.service.GroupService;
import mops.gruppen2.service.InviteLinkRepositoryService;
import mops.gruppen2.service.KeyCloakService;
import mops.gruppen2.service.UserService;
import org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException;
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
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.context.annotation.SessionScope;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.security.RolesAllowed;
import java.io.CharConversionException;
import java.io.IOException;
@ -84,11 +82,12 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
@PostMapping("/createOrga")
public String pCreateOrga(KeycloakAuthenticationToken token,
@RequestParam("title") String title,
@RequestParam("beschreibung") String beschreibung,
@RequestParam(value = "visibility", required = false) Boolean visibility,
@RequestParam(value = "lecture", required = false) Boolean lecture,
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException {
@RequestParam("title") String title,
@RequestParam("description") String description,
@RequestParam(value = "visibility", required = false) Boolean visibility,
@RequestParam(value = "lecture", required = false) Boolean lecture,
@RequestParam("userMaximum") Long userMaximum,
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException {
Account account = keyCloakService.createAccountFromPrincipal(token);
List<User> userList = new ArrayList<>();
@ -102,7 +101,7 @@ public class Gruppen2Controller {
visibility = visibility == null;
lecture = lecture == null;
controllerService.createOrga(account, title, beschreibung, visibility, lecture, userList);
controllerService.createOrga(account, title, description, visibility, lecture, userMaximum, userList);
return "redirect:/gruppen2/";
}
@ -117,13 +116,14 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_studentin"})
@PostMapping("/createStudent")
public String pCreateStudent(KeycloakAuthenticationToken token,
@RequestParam("title") String title,
@RequestParam("beschreibung") String beschreibung,
@RequestParam(value = "visibility", required = false) Boolean visibility) throws EventException {
@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, beschreibung, visibility);
controllerService.createGroup(account, title, description, visibility, userMaximum);
return "redirect:/gruppen2/";
}
@ -138,8 +138,6 @@ public class Gruppen2Controller {
userList = CsvService.read(file.getInputStream());
} catch (UnrecognizedPropertyException | CharConversionException ex) {
throw new WrongFileException(file.getOriginalFilename());
} catch (IllegalStateException ex) {
throw new WrongFileException(file.getOriginalFilename());
}
}
controllerService.addUserList(userList, groupId);
@ -159,21 +157,6 @@ public class Gruppen2Controller {
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)"})
@GetMapping("/details/{id}")
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable("id") Long groupId) throws EventException {

View File

@ -66,7 +66,7 @@ public class ControllerService {
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;
Long groupId = eventService.checkGroup();
@ -82,7 +82,8 @@ public class ControllerService {
} else {
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);
addUser(account, groupId);
@ -163,26 +164,6 @@ public class ControllerService {
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){
Group group = userService.getGroupById(groupId);
if (group.getMembers().size() <= 1){

View File

@ -47,9 +47,14 @@
type="text">
</div>
<div class="form-group">
<label for="beschreibung">Beschreibung</label>
<textarea class="form-control" id="beschreibung" required
rows="3" th:name="beschreibung"></textarea>
<label for="description">Beschreibung</label>
<textarea class="form-control" id="description" required
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 class="custom-control custom-checkbox">
<input class="custom-control-input" id="visibility" th:name="visibility"

View File

@ -33,7 +33,7 @@
<div class="row">
<div class="col-10">
<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="form-group">