Hello,
I’m just wondering is there a call to query a users permissions group via API
Hello,
I’m just wondering is there a call to query a users permissions group via API
Okay have it figured out
def get_user_permission_level(user_name):
"""
Function that returns users permissions level as a string
"""
cur_obj = sgtk.platform.current_engine()
if ' ' in user_name:
filters = [['sg_status_list', 'is', 'act'], ['name', 'is', user_name]]
else:
filters = [['sg_status_list', 'is', 'act'], ['login', 'is', user_name]]
fields = ['permission_rule_set']
project_users = cur_obj.shotgun.find_one("HumanUser", filters, fields)
if project_users:
return project_users['permission_rule_set']['name'].lower()
else:
return None
That looks great!
Also just to add for anyone else who sees this, you can get the current Shotgun user login by doing the following:
import sgtk
engine = sgtk.platform.current_engine()
print engine.context.user
>> {'name': 'Bob Smith',
'firstname': 'Bob',
'lastname': 'Smith',
'image': None,
'id': 88,
'login': 'bob',
'type': 'HumanUser',
'email': 'bob.smith@acompany.com'}