def list_group_members(self, pk): res = UserResource() bundles = [] for u in hydroshare.list_group_members(pk): bundle = res.build_bundle(obj=u, request=self.request) bundles.append(res.full_dehydrate(bundle, for_list=True)) list_json = res.serialize(None, bundles, "application/json") return json_or_jsonp(self.request, list_json)
def list_groups(self): params = CreateOrListGroups.ListGroupsForm(self.request.REQUEST) if params.is_valid(): r = params.cleaned_data res = UserResource() bundles = [] for u in hydroshare.list_users(r['query'], r['status'], r['start'], r['count']): bundle = res.build_bundle(obj=u, request=self.request) bundles.append(res.full_dehydrate(bundle, for_list=True)) list_json = res.serialize(None, bundles, "application/json") return json_or_jsonp(self.request, list_json) else: raise exceptions.ValidationError('invalid request')
def list_users(self): params = utils.create_form(CreateOrListAccounts.ListUsersForm, self.request) if params.is_valid(): r = params.cleaned_data res = UserResource() bundles = [] for u in hydroshare.list_users(r['query'], r['status'], r['start'], r['count']): bundle = res.build_bundle(obj=u, request=self.request) bundles.append(res.full_dehydrate(bundle, for_list=True)) list_json = res.serialize(None, bundles, "application/json") return json_or_jsonp(self.request, list_json) else: raise exceptions.ValidationError('invalid request')
def get_user_info(user): """ Get the information about a user identified by userID. This would be their profile information, groups they belong. REST URL: GET /accounts/{userID} Parameters: userID - ID of the existing user to be modified Returns: An object containing the details for the user Return Type: user Raises: Exceptions.NotAuthorized - The user is not authorized Exceptions.NotFound - The user identified by userID does not exist Exception.ServiceFailure - The service is unable to process the request """ from hs_core.api import UserResource ur = UserResource() ur_bundle = ur.build_bundle(obj=user) return json.loads(ur.serialize(None, ur.full_dehydrate(ur_bundle), 'application/json'))
def _get_user_info(user): from hs_core.api import UserResource ur = UserResource() ur_bundle = ur.build_bundle(obj=user) return json.loads(ur.serialize(None, ur.full_dehydrate(ur_bundle), 'application/json'))