add DeleteGoup function
Co-Authored-By: Talha Caliskan <killerber4t@users.noreply.github.com>
This commit is contained in:
@ -174,6 +174,9 @@ public class Gruppen2Controller {
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
Long parentId = group.getParent();
|
||||
Group parent = new Group();
|
||||
if(group.getTitle() == null){
|
||||
throw new GroupNotFoundException(this.getClass().toString());
|
||||
}
|
||||
if (parentId != null) {
|
||||
parent = userService.getGroupById(parentId);
|
||||
}
|
||||
@ -247,6 +250,15 @@ public class Gruppen2Controller {
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||
@PostMapping("/deleteGroup")
|
||||
public String pDeleteGroup(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId){
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
controllerService.deleteGroupEvent(user, groupId);
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@GetMapping("/details/members/{id}")
|
||||
public String editMembers(Model model, KeycloakAuthenticationToken token, @PathVariable("id") Long groupId) throws EventException {
|
||||
|
||||
@ -21,6 +21,7 @@ import mops.gruppen2.domain.exception.GroupIdMismatchException;
|
||||
@JsonSubTypes.Type(value = UpdateGroupDescriptionEvent.class, name = "UpdateGroupDescriptionEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
|
||||
@JsonSubTypes.Type(value = DeleteGroupEvent.class, name = "DeleteGroupEvent")
|
||||
})
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
|
||||
@ -102,6 +102,9 @@ public class GroupService {
|
||||
List<Group> visibleGroups = projectEventList(eventsVisible);
|
||||
List<Group> visibleLectures = new ArrayList<>();
|
||||
for (Group group : visibleGroups) {
|
||||
if(group.getType() == null){
|
||||
continue;
|
||||
}
|
||||
if (group.getType().equals(GroupType.LECTURE)) {
|
||||
visibleLectures.add(group);
|
||||
}
|
||||
@ -121,6 +124,9 @@ public class GroupService {
|
||||
public List<Group> findGroupWith(String search, Account account) throws EventException {
|
||||
List<Group> groups = new ArrayList<>();
|
||||
for (Group group : getAllGroupWithVisibilityPublic(account.getName())) {
|
||||
if(group.getType() == null){
|
||||
continue;
|
||||
}
|
||||
if (group.getTitle().toLowerCase().contains(search.toLowerCase()) || group.getDescription().toLowerCase().contains(search.toLowerCase())) {
|
||||
groups.add(group);
|
||||
}
|
||||
|
||||
@ -59,6 +59,12 @@
|
||||
type="submit">Gruppe verlassen
|
||||
</button>
|
||||
</form>
|
||||
<form action="/gruppen2/deleteGroup" method="post">
|
||||
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
||||
th:name="group_id" th:value="${group.getId()}"
|
||||
type="submit">Gruppe löschen
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3" style="white-space: nowrap">
|
||||
|
||||
Reference in New Issue
Block a user