def resource_get(self, resource_id): request = self.request resource = ResourceService.get(safe_integer(resource_id), db_session=request.dbsession) if not resource: raise pyramid.httpexceptions.HTTPNotFound() return resource
def user_get(self, user_id): request = self.request user = UserService.get(safe_integer(user_id), db_session=request.dbsession) if not user: raise pyramid.httpexceptions.HTTPNotFound() return user
def entry_get(self, entry_id): request = self.request entry = EntryService.get(safe_integer(entry_id), db_session=request.dbsession) if not entry: raise pyramid.httpexceptions.HTTPNotFound() return entry
def collection_list(self): page = safe_integer(self.request.GET.get('page', 1)) user_paginator = self.shared.collection_list(page=page) start_number = (USERS_PER_PAGE * (self.shared.page - 1) + 1) or 1 user_grid = UsersGrid(user_paginator, start_number=start_number, request=self.request) return {'user_paginator': user_paginator, 'user_grid': user_grid}
def collection_list(self): page = safe_integer(self.request.GET.get("page", 1)) user_paginator = self.shared.collection_list(page=page) start_number = (USERS_PER_PAGE * (self.shared.page - 1) + 1) or 1 user_grid = UsersGrid( user_paginator, start_number=start_number, request=self.request ) return {"user_paginator": user_paginator, "user_grid": user_grid}
def collection_list(self): schema = EntryCreateSchema(context={'request': self.request}) page = safe_integer(self.request.GET.get('page', 1)) filter_params = self.request.GET.mixed() entries_paginator = self.shared.collection_list( page=page, filter_params=filter_params) headers = gen_pagination_headers(request=self.request, paginator=entries_paginator) self.request.response.headers.update(headers) return schema.dump(entries_paginator.items, many=True).data
def collection_list(self): schema = UserCreateSchema(context={"request": self.request}) page = safe_integer(self.request.GET.get("page", 1)) filter_params = UserSearchSchema().load(self.request.GET.mixed()).data user_paginator = self.shared.collection_list( page=page, filter_params=filter_params ) headers = gen_pagination_headers(request=self.request, paginator=user_paginator) self.request.response.headers.update(headers) return schema.dump(user_paginator.items, many=True).data
def users_get(self): request = self.request group = self.shared.group_get(request.matchdict['object_id']) page = safe_integer(request.GET.get('page', 1)) user_paginator = GroupService.get_user_paginator( group, page=page, items_per_page=GROUPS_PER_PAGE, url_maker=lambda p: request.current_route_url(_query={"page": p}), db_session=request.dbsession) user_grid = UsersGroupsGrid(user_paginator, columns=[ "_numbered", "user_name", "email", "registered_date", "options" ], start_number=GROUPS_PER_PAGE * (page - 1) or 1, request=request, group=group) return {"group": group, "user_grid": user_grid}
def __init__(self, request): self.__acl__ = [] resource_id = safe_integer(request.matchdict.get("object_id")) self.resource = ResourceService.by_resource_id( resource_id, db_session=request.dbsession) if not self.resource: raise HTTPNotFound() if self.resource: self.__acl__ = self.resource.__acl__ if self.resource and request.user: # add perms that this user has for this resource # this is a big performance optimization - we fetch only data # needed to check one specific user permissions = ResourceService.perms_for_user( self.resource, request.user) for outcome, perm_user, perm_name in permission_to_pyramid_acls( permissions): self.__acl__.append( rewrite_root_perm(outcome, perm_user, perm_name)) allow_root_access(request, context=self)
def __init__(self, request): self.__acl__ = [] resource_id = safe_integer(request.matchdict.get("object_id")) self.resource = ResourceService.by_resource_id( resource_id, db_session=request.dbsession ) if not self.resource: raise HTTPNotFound() if self.resource: self.__acl__ = self.resource.__acl__ if self.resource and request.user: # add perms that this user has for this resource # this is a big performance optimization - we fetch only data # needed to check one specific user permissions = ResourceService.perms_for_user(self.resource, request.user) for outcome, perm_user, perm_name in permission_to_pyramid_acls( permissions ): self.__acl__.append(rewrite_root_perm(outcome, perm_user, perm_name)) allow_root_access(request, context=self)