Merge branch 'master' into design-fix
This commit is contained in:
@ -8,8 +8,11 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class Gruppen2Config {
|
public class Gruppen2Config {
|
||||||
|
|
||||||
@Autowired
|
final GroupService groupService;
|
||||||
GroupService groupService;
|
final EventService eventService;
|
||||||
@Autowired
|
|
||||||
EventService eventService;
|
public Gruppen2Config(GroupService groupService, EventService eventService) {
|
||||||
|
this.groupService = groupService;
|
||||||
|
this.eventService = eventService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,15 +43,15 @@ public class Gruppen2Controller {
|
|||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final ControllerService controllerService;
|
private final ControllerService controllerService;
|
||||||
private final InviteLinkRepositoryService inviteLinkRepositoryService;
|
private final InviteLinkRepositoryService inviteLinkRepositoryService;
|
||||||
@Autowired
|
private final Gruppen2Config gruppen2Config;
|
||||||
Gruppen2Config gruppen2Config;
|
|
||||||
|
|
||||||
public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService) {
|
public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService, Gruppen2Config gruppen2Config) {
|
||||||
this.keyCloakService = keyCloakService;
|
this.keyCloakService = keyCloakService;
|
||||||
this.groupService = groupService;
|
this.groupService = groupService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.controllerService = controllerService;
|
this.controllerService = controllerService;
|
||||||
this.inviteLinkRepositoryService = inviteLinkRepositoryService;
|
this.inviteLinkRepositoryService = inviteLinkRepositoryService;
|
||||||
|
this.gruppen2Config = gruppen2Config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,6 +97,9 @@ public class Gruppen2Controller {
|
|||||||
if (!file.isEmpty()) {
|
if (!file.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
userList = CsvService.read(file.getInputStream());
|
userList = CsvService.read(file.getInputStream());
|
||||||
|
if(userList.size() > userMaximum){
|
||||||
|
userMaximum = Long.valueOf(userList.size()) + userMaximum;
|
||||||
|
}
|
||||||
} catch (UnrecognizedPropertyException | CharConversionException ex) {
|
} catch (UnrecognizedPropertyException | CharConversionException ex) {
|
||||||
throw new WrongFileException(file.getOriginalFilename());
|
throw new WrongFileException(file.getOriginalFilename());
|
||||||
}
|
}
|
||||||
@ -258,6 +261,10 @@ public class Gruppen2Controller {
|
|||||||
public String pDeleteGroup(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId){
|
public String pDeleteGroup(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId){
|
||||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||||
|
Group group = userService.getGroupById(groupId);
|
||||||
|
if(group.getRoles().get(user.getId()) != Role.ADMIN ){
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
controllerService.deleteGroupEvent(user.getId(), groupId);
|
controllerService.deleteGroupEvent(user.getId(), groupId);
|
||||||
return "redirect:/gruppen2/";
|
return "redirect:/gruppen2/";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public class AddUserEvent extends Event {
|
|||||||
if (group.getMembers().contains(user)) {
|
if (group.getMembers().contains(user)) {
|
||||||
throw new UserAlreadyExistsException(this.getClass().toString());
|
throw new UserAlreadyExistsException(this.getClass().toString());
|
||||||
}
|
}
|
||||||
//andere exception
|
|
||||||
if (group.getMembers().size() == group.getUserMaximum()){
|
if (group.getMembers().size() == group.getUserMaximum()){
|
||||||
throw new GroupFullException(this.getClass().toString());
|
throw new GroupFullException(this.getClass().toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@
|
|||||||
<div class="form-group mt-3">
|
<div class="form-group mt-3">
|
||||||
<label for="userMaximum">Teilnehmeranzahl</label>
|
<label for="userMaximum">Teilnehmeranzahl</label>
|
||||||
<input class="form-control" id="userMaximum" required th:name="userMaximum"
|
<input class="form-control" id="userMaximum" required th:name="userMaximum"
|
||||||
type="number" min="1">
|
type="number" min="1" max="10000">
|
||||||
</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"
|
||||||
|
|||||||
@ -61,7 +61,7 @@
|
|||||||
</form>
|
</form>
|
||||||
<form action="/gruppen2/deleteGroup" method="post">
|
<form action="/gruppen2/deleteGroup" method="post">
|
||||||
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
||||||
th:name="group_id" th:value="${group.getId()}"
|
th:name="group_id" th:value="${group.getId()}" th:if="${group.getRoles().get(user.getId()) == admin}"
|
||||||
type="submit">Gruppe löschen
|
type="submit">Gruppe löschen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user