class Folder(RESTDispatch): def __init__(self): self._session = SessionManagement() self._access = AccessManagement() self._user = UserManagement() def GET(self, request, **kwargs): folder_id = kwargs.get('folder_id') if (folder_id): return self._get_folder_details(space_id) else: params = {} for q in request.GET: params[q] = request.GET.get(q) return self._list_folders(params) def _get_folder_details(self, space_id): return self.json_response('{}') def _list_folders(self, args): folders = [] if 'search' in args: search = args['search'].strip() if len(search) > 3: for folder in self._session.getFoldersList(search_query=search): creators = [] viewers = [] deets = self._access.getFolderAccessDetails(folder['Id']) if deets.UsersWithCreatorAccess: response = self._user.getUsers(deets.UsersWithCreatorAccess.guid) if response and response.User: for user in response.User: match = re.match(r'^%s\\(.+)$' % (settings.PANOPTO_API_APP_ID), user.UserKey) creators.append({ 'key': match.group(1) if match else user.UserKey, 'id': user.UserId }) if deets.UsersWithViewerAccess: response = self._user.getUsers(deets.UsersWithCreatorAccess.guid) if response and response.User: for user in response.User: match = re.match(r'^%s\\(.+)$' % (settings.PANOPTO_API_APP_ID), user.UserKey) viewers.append({ 'key': match.group(1) if match else user.UserKey, 'id': user.UserId }) folders.append({ 'name': folder.Name, 'id': folder.Id, 'auth' : { 'creators': creators, 'viewers': viewers } }) return self.json_response(folders)
class Folder(RESTDispatch): def __init__(self): self._session = SessionManagement() self._access = AccessManagement() self._user = UserManagement() def GET(self, request, **kwargs): folder_id = kwargs.get("folder_id") if folder_id: return self._get_folder_details(space_id) else: params = {} for q in request.GET: params[q] = request.GET.get(q) return self._list_folders(params) def _get_folder_details(self, space_id): return self.json_response("{}") def _list_folders(self, args): folders = [] if "search" in args: search = args["search"].strip() if len(search) > 3: for folder in self._session.getFoldersList(search_query=search): creators = [] viewers = [] deets = self._access.getFolderAccessDetails(folder["Id"]) if deets.UsersWithCreatorAccess: response = self._user.getUsers(deets.UsersWithCreatorAccess.guid) if response and response.User: for user in response.User: match = re.match(r"^%s\\(.+)$" % (settings.PANOPTO_API_APP_ID), user.UserKey) creators.append({"key": match.group(1) if match else user.UserKey, "id": user.UserId}) if deets.UsersWithViewerAccess: response = self._user.getUsers(deets.UsersWithCreatorAccess.guid) if response and response.User: for user in response.User: match = re.match(r"^%s\\(.+)$" % (settings.PANOPTO_API_APP_ID), user.UserKey) viewers.append({"key": match.group(1) if match else user.UserKey, "id": user.UserId}) folders.append( {"name": folder.Name, "id": folder.Id, "auth": {"creators": creators, "viewers": viewers}} ) return self.json_response(folders)
def get_panopto_folder_creators(folder_id): user_api = UserManagement() access_api = AccessManagement() creators = [] folder_access = access_api.getFolderAccessDetails(folder_id) if len(folder_access['UsersWithCreatorAccess']): guids = folder_access['UsersWithCreatorAccess'][0] if len(guids): users = user_api.getUsers(guids) for user in users[0]: match = re.match(r'^%s\\(.+)$' % (settings.PANOPTO_API_APP_ID), user['UserKey']) if match: creators.append(match.group(1) if match else user['UserKey']) return creators
def get_panopto_folder_creators(folder_id): user_api = UserManagement() access_api = AccessManagement() creators = [] folder_access = access_api.getFolderAccessDetails(folder_id) if len(folder_access['UsersWithCreatorAccess']): guids = folder_access['UsersWithCreatorAccess'][0] if len(guids): users = user_api.getUsers(guids) for user in users[0]: match = re.match(r'^%s\\(.+)$' % (settings.PANOPTO_API_APP_ID), user['UserKey']) if match: creators.append( match.group(1) if match else user['UserKey']) return creators