Page 1 of 1

test for group owner

PostPosted: Wed Oct 24, 2012 6:56 am
by Manz
Hey Guys

Do you have a check for "is this person in this conn. a group owner or just in the group"? or even just a "who is group owner" ?

Thanks
Manda

Re: test for group owner

PostPosted: Wed Oct 24, 2012 8:15 am
by cxallan
Sure.

For the currently logged in user...

Code: Select all
session = client.getSession()
ec = session.getAdminService().getEventContext()
ec.leaderOfGroups  # The groups this user is a "leader" or "owner" of
ec.memberOfGroups  # The groups this user is a "member" of


For a given group...

Code: Select all
session = client.getSession()
group = session.getAdminService().lookupGroup("name-of-group")
for map in group.copyGroupExperimenterMap():  # The mappings of users in the current group
    if map.owner:  # The user is an owner or "leader" of the current group
        experimenter = map.child  # The "child" is an Experimenter instance
        print experimenter.name.val

Re: test for group owner

PostPosted: Wed Oct 24, 2012 8:25 am
by wmoore
From Python Blitz Gateway you can get event context directly from 'conn':

Code: Select all
ec = conn.getEventContext()


There's also conn.isLeader() or conn.isLeader(groupId):

Code: Select all
def isLeader(self, gid=None):
        """
        Is the current group (or a specified group) led by the current user?

        @return:    True if user leads the current group
        @rtype:     Boolean
        """