mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 05:53:00 +00:00
Change group.users pagination to use slices
This commit is contained in:
@@ -104,6 +104,9 @@ class GroupAPIHandler(_GroupAPIHandler):
|
|||||||
group = self.find_group(name)
|
group = self.find_group(name)
|
||||||
users_slice = None
|
users_slice = None
|
||||||
|
|
||||||
|
print(type(group.users))
|
||||||
|
print(group.users)
|
||||||
|
|
||||||
if offset is not None:
|
if offset is not None:
|
||||||
try:
|
try:
|
||||||
offset = int(offset)
|
offset = int(offset)
|
||||||
@@ -112,7 +115,7 @@ class GroupAPIHandler(_GroupAPIHandler):
|
|||||||
400, "Invalid argument type, offset must be an integer"
|
400, "Invalid argument type, offset must be an integer"
|
||||||
)
|
)
|
||||||
|
|
||||||
users_slice = group.users.offset(int(offset))
|
group.users = group.users[offset:]
|
||||||
|
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
try:
|
try:
|
||||||
@@ -122,10 +125,7 @@ class GroupAPIHandler(_GroupAPIHandler):
|
|||||||
400, "Invalid argument type, limit must be an integer"
|
400, "Invalid argument type, limit must be an integer"
|
||||||
)
|
)
|
||||||
|
|
||||||
if users_slice is not None:
|
group.users = group.users[:limit]
|
||||||
users_slice = users_slice.limit(int(limit))
|
|
||||||
else:
|
|
||||||
users_slice = group.users.limit(int(limit))
|
|
||||||
|
|
||||||
group_model = self.group_model(group)
|
group_model = self.group_model(group)
|
||||||
|
|
||||||
|
@@ -128,9 +128,7 @@ class Group(Base):
|
|||||||
__tablename__ = 'groups'
|
__tablename__ = 'groups'
|
||||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
name = Column(Unicode(255), unique=True)
|
name = Column(Unicode(255), unique=True)
|
||||||
users = relationship(
|
users = relationship('User', secondary='user_group_map', backref='groups')
|
||||||
'User', secondary='user_group_map', backref='groups', lazy="dynamic"
|
|
||||||
)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s %s (%i users)>" % (
|
return "<%s %s (%i users)>" % (
|
||||||
|
Reference in New Issue
Block a user