Skip to content
Snippets Groups Projects
Commit 166bddf7 authored by Julian's avatar Julian
Browse files

Allow getting a group by id

parent 062cb7a5
No related branches found
No related tags found
1 merge request!1261Manage holidays
Pipeline #135382 passed with warnings
......@@ -72,6 +72,7 @@ class Query(graphene.ObjectType):
person_by_id_or_me = graphene.Field(PersonType, id=graphene.ID())
groups = graphene.List(GroupType)
group_by_id = graphene.Field(GroupType, id=graphene.ID())
who_am_i = graphene.Field(UserType)
......@@ -144,6 +145,19 @@ class Query(graphene.ObjectType):
def resolve_groups(root, info, **kwargs):
return get_objects_for_user(info.context.user, "core.view_group", Group)
@staticmethod
def resolve_group_by_id(root, info, id):
group = Group.objects.filter(id=id)
if len(group) != 1:
return None
group = group.first()
if not info.context.user.has_perm("core.view_group", group):
raise PermissionDenied()
return group
def resolve_who_am_i(root, info, **kwargs):
return info.context.user
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment