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());
|
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||||
Long parentId = group.getParent();
|
Long parentId = group.getParent();
|
||||||
Group parent = new Group();
|
Group parent = new Group();
|
||||||
|
if(group.getTitle() == null){
|
||||||
|
throw new GroupNotFoundException(this.getClass().toString());
|
||||||
|
}
|
||||||
if (parentId != null) {
|
if (parentId != null) {
|
||||||
parent = userService.getGroupById(parentId);
|
parent = userService.getGroupById(parentId);
|
||||||
}
|
}
|
||||||
@ -247,6 +250,15 @@ public class Gruppen2Controller {
|
|||||||
return "redirect:/gruppen2/";
|
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)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||||
@GetMapping("/details/members/{id}")
|
@GetMapping("/details/members/{id}")
|
||||||
public String editMembers(Model model, KeycloakAuthenticationToken token, @PathVariable("id") Long groupId) throws EventException {
|
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 = UpdateGroupDescriptionEvent.class, name = "UpdateGroupDescriptionEvent"),
|
||||||
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
|
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
|
||||||
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
|
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
|
||||||
|
@JsonSubTypes.Type(value = DeleteGroupEvent.class, name = "DeleteGroupEvent")
|
||||||
})
|
})
|
||||||
@Getter
|
@Getter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|||||||
@ -102,6 +102,9 @@ public class GroupService {
|
|||||||
List<Group> visibleGroups = projectEventList(eventsVisible);
|
List<Group> visibleGroups = projectEventList(eventsVisible);
|
||||||
List<Group> visibleLectures = new ArrayList<>();
|
List<Group> visibleLectures = new ArrayList<>();
|
||||||
for (Group group : visibleGroups) {
|
for (Group group : visibleGroups) {
|
||||||
|
if(group.getType() == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (group.getType().equals(GroupType.LECTURE)) {
|
if (group.getType().equals(GroupType.LECTURE)) {
|
||||||
visibleLectures.add(group);
|
visibleLectures.add(group);
|
||||||
}
|
}
|
||||||
@ -121,6 +124,9 @@ public class GroupService {
|
|||||||
public List<Group> findGroupWith(String search, Account account) throws EventException {
|
public List<Group> findGroupWith(String search, Account account) throws EventException {
|
||||||
List<Group> groups = new ArrayList<>();
|
List<Group> groups = new ArrayList<>();
|
||||||
for (Group group : getAllGroupWithVisibilityPublic(account.getName())) {
|
for (Group group : getAllGroupWithVisibilityPublic(account.getName())) {
|
||||||
|
if(group.getType() == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (group.getTitle().toLowerCase().contains(search.toLowerCase()) || group.getDescription().toLowerCase().contains(search.toLowerCase())) {
|
if (group.getTitle().toLowerCase().contains(search.toLowerCase()) || group.getDescription().toLowerCase().contains(search.toLowerCase())) {
|
||||||
groups.add(group);
|
groups.add(group);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,6 +59,12 @@
|
|||||||
type="submit">Gruppe verlassen
|
type="submit">Gruppe verlassen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</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>
|
</div>
|
||||||
<div class="col-3" style="white-space: nowrap">
|
<div class="col-3" style="white-space: nowrap">
|
||||||
|
|||||||
Reference in New Issue
Block a user