From 5c921c854e46809eb336d05581d5dee0e74054d6 Mon Sep 17 00:00:00 2001 From: hoang Date: Fri, 25 Sep 2026 16:49:41 +0700 Subject: [PATCH] Fix bug that user unable to see group after creating via API We have resolved an issue where users were unable to see Groups created through the API. The root cause was that users were not automatically assigned as Group Admins, unlike when groups are created via the Web interface. --- promgen/rest_v2.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/promgen/rest_v2.py b/promgen/rest_v2.py index 1a149924..cdf8b3e4 100644 --- a/promgen/rest_v2.py +++ b/promgen/rest_v2.py @@ -930,6 +930,12 @@ def get_queryset(self): return self.queryset return permissions.get_accessible_groups_for_user(self.request.user) + def perform_create(self, serializer): + group = serializer.save() + # Assign the user who created the group as the first admin of the group + group.user_set.add(self.request.user) + assign_perm("group_admin", self.request.user, group) + @extend_schema( summary="List Members", description="Retrieve a list of all members in the specific group.",