Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nomad-FAIR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nomad-lab
nomad-FAIR
Commits
e87dac67
Commit
e87dac67
authored
10 months ago
by
Sascha Klawohn
Browse files
Options
Downloads
Patches
Plain Diff
Make get_by_ids accept str
parent
bbed6514
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1979
Get groups filters
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nomad/groups.py
+5
-3
5 additions, 3 deletions
nomad/groups.py
with
5 additions
and
3 deletions
nomad/groups.py
+
5
−
3
View file @
e87dac67
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#
#
import
operator
import
operator
from
functools
import
reduce
from
functools
import
reduce
from
typing
import
Iterable
,
List
,
Optional
from
typing
import
Iterable
,
Optional
,
Union
from
mongoengine
import
Document
,
ListField
,
StringField
from
mongoengine
import
Document
,
ListField
,
StringField
from
mongoengine.queryset.visitor
import
Q
from
mongoengine.queryset.visitor
import
Q
...
@@ -40,10 +40,12 @@ class UserGroup(Document):
...
@@ -40,10 +40,12 @@ class UserGroup(Document):
meta
=
{
'
indexes
'
:
[
'
group_name
'
,
'
owner
'
,
'
members
'
]}
meta
=
{
'
indexes
'
:
[
'
group_name
'
,
'
owner
'
,
'
members
'
]}
@classmethod
@classmethod
def
get_by_ids
(
cls
,
group_ids
:
Iterable
[
str
]):
def
get_by_ids
(
cls
,
group_ids
:
Union
[
str
,
Iterable
[
str
]
]
):
"""
"""
Returns UserGroup objects with group_ids.
Returns UserGroup objects with group_ids.
"""
"""
if
not
isinstance
(
group_ids
,
Iterable
):
group_ids
=
[
group_ids
]
user_groups
=
cls
.
objects
(
group_id__in
=
group_ids
)
user_groups
=
cls
.
objects
(
group_id__in
=
group_ids
)
return
user_groups
return
user_groups
...
@@ -58,7 +60,7 @@ class UserGroup(Document):
...
@@ -58,7 +60,7 @@ class UserGroup(Document):
return
user_groups
return
user_groups
@classmethod
@classmethod
def
get_ids_by_user_id
(
cls
,
user_id
:
Optional
[
str
],
include_all
=
True
)
->
L
ist
[
str
]:
def
get_ids_by_user_id
(
cls
,
user_id
:
Optional
[
str
],
include_all
=
True
)
->
l
ist
[
str
]:
"""
"""
Returns ids of all user groups where user_id is owner or member.
Returns ids of all user groups where user_id is owner or member.
Does include special group
'
all
'
, even if user_id is missing or not a user.
Does include special group
'
all
'
, even if user_id is missing or not a user.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment