Add pagination to org users
This commit is contained in:
parent
998182f65e
commit
d4db6bc0be
1 changed files with 8 additions and 2 deletions
|
@ -304,15 +304,18 @@ class OrganizationHome(OrganizationHomeView, FeedView):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class OrganizationUsers(QueryStringSortMixin, OrganizationMixin, ListView):
|
class OrganizationUsers(
|
||||||
|
DiggPaginatorMixin, QueryStringSortMixin, OrganizationMixin, ListView
|
||||||
|
):
|
||||||
template_name = "organization/users.html"
|
template_name = "organization/users.html"
|
||||||
all_sorts = frozenset(("points", "problem_count", "rating", "performance_points"))
|
all_sorts = frozenset(("points", "problem_count", "rating", "performance_points"))
|
||||||
default_desc = all_sorts
|
default_desc = all_sorts
|
||||||
default_sort = "-performance_points"
|
default_sort = "-performance_points"
|
||||||
|
paginate_by = 100
|
||||||
context_object_name = "users"
|
context_object_name = "users"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return ranker(
|
return (
|
||||||
self.organization.members.filter(is_unlisted=False)
|
self.organization.members.filter(is_unlisted=False)
|
||||||
.order_by(self.order, "id")
|
.order_by(self.order, "id")
|
||||||
.select_related("user")
|
.select_related("user")
|
||||||
|
@ -347,6 +350,9 @@ class OrganizationUsers(QueryStringSortMixin, OrganizationMixin, ListView):
|
||||||
"organization_user_kick",
|
"organization_user_kick",
|
||||||
args=[self.organization.id, self.organization.slug],
|
args=[self.organization.id, self.organization.slug],
|
||||||
)
|
)
|
||||||
|
context["users"] = ranker(
|
||||||
|
context["users"], rank=self.paginate_by * (context["page_obj"].number - 1)
|
||||||
|
)
|
||||||
|
|
||||||
context["first_page_href"] = "."
|
context["first_page_href"] = "."
|
||||||
context["page_type"] = "users"
|
context["page_type"] = "users"
|
||||||
|
|
Loading…
Reference in a new issue