Commit da1def0b authored by jens.kleineheismann's avatar jens.kleineheismann

UPD: Added new parameter 'effective' to models.User.get_goups().

parent 30265826
......@@ -4,7 +4,7 @@ Library for accessing the KIT Gruppenverwaltung REST API
The object, you are looking for is kitgvapi.ObjectInterface.
"""
__version__ = '1.3'
__version__ = '1.3.1'
__author__ = 'Jens Kleineheismann'
__email__ = 'kleineheismann@kit.edu'
__license__ = """
......
......@@ -140,9 +140,13 @@ class RestClient(object):
path = '/identities/get/{pk}'.format(pk=pk)
return self.get(path)
def get_user_groups(self, pk, pk_only=False):
def get_user_groups(self, pk, pk_only=False, effective=False):
path = '/identities/get/{pk}/memberof'.format(pk=pk)
l = self.get(path)
if effective:
res = 'all'
else:
res = 'direct'
l = self.get(path)[res]
if pk_only:
l = [d[SYMBOLS['GROUP_PK_ATTRIB']] for d in l]
return l
......
......@@ -140,9 +140,9 @@ class User(Model):
def _save_data_attribs(self):
raise NotImplementedError('Not supported')
def get_groups(self):
def get_groups(self, effective=False):
self.load()
l = self.client.get_user_groups(pk=self.pk)
for d in l['all']:
l = self.client.get_user_groups(pk=self.pk, effective=effective)
for d in l:
y = Group(client=self.client, data=d)
yield y
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment