forked from mirrors/bookwyrm
Merge pull request #965 from bookwyrm-social/pagination-cleanup
Pagination cleanup
This commit is contained in:
commit
7ffc300bb1
13 changed files with 33 additions and 100 deletions
|
@ -47,7 +47,7 @@ class List(OrderedCollectionMixin, BookWyrmModel):
|
||||||
@property
|
@property
|
||||||
def collection_queryset(self):
|
def collection_queryset(self):
|
||||||
""" list of books for this shelf, overrides OrderedCollectionMixin """
|
""" list of books for this shelf, overrides OrderedCollectionMixin """
|
||||||
return self.books.filter(listitem__approved=True).all().order_by("listitem")
|
return self.books.filter(listitem__approved=True).order_by("listitem")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
""" default sorting """
|
""" default sorting """
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
|
||||||
@property
|
@property
|
||||||
def collection_queryset(self):
|
def collection_queryset(self):
|
||||||
""" list of books for this shelf, overrides OrderedCollectionMixin """
|
""" list of books for this shelf, overrides OrderedCollectionMixin """
|
||||||
return self.books.all().order_by("shelfbook")
|
return self.books.order_by("shelfbook")
|
||||||
|
|
||||||
def get_remote_id(self):
|
def get_remote_id(self):
|
||||||
""" shelf identifier instead of id """
|
""" shelf identifier instead of id """
|
||||||
|
|
|
@ -62,14 +62,10 @@ def get_notification_count(user):
|
||||||
def get_replies(status):
|
def get_replies(status):
|
||||||
""" get all direct replies to a status """
|
""" get all direct replies to a status """
|
||||||
# TODO: this limit could cause problems
|
# TODO: this limit could cause problems
|
||||||
return (
|
return models.Status.objects.filter(
|
||||||
models.Status.objects.filter(
|
|
||||||
reply_parent=status,
|
reply_parent=status,
|
||||||
deleted=False,
|
deleted=False,
|
||||||
)
|
).select_subclasses()[:10]
|
||||||
.select_subclasses()
|
|
||||||
.all()[:10]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@register.filter(name="parent")
|
@register.filter(name="parent")
|
||||||
|
|
|
@ -30,11 +30,6 @@ class Book(View):
|
||||||
|
|
||||||
def get(self, request, book_id):
|
def get(self, request, book_id):
|
||||||
""" info about a book """
|
""" info about a book """
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
book = models.Book.objects.select_subclasses().get(id=book_id)
|
book = models.Book.objects.select_subclasses().get(id=book_id)
|
||||||
except models.Book.DoesNotExist:
|
except models.Book.DoesNotExist:
|
||||||
|
@ -60,7 +55,7 @@ class Book(View):
|
||||||
paginated = Paginator(
|
paginated = Paginator(
|
||||||
reviews.exclude(Q(content__isnull=True) | Q(content="")), PAGE_LENGTH
|
reviews.exclude(Q(content__isnull=True) | Q(content="")), PAGE_LENGTH
|
||||||
)
|
)
|
||||||
reviews_page = paginated.get_page(page)
|
reviews_page = paginated.get_page(request.GET.get("page"))
|
||||||
|
|
||||||
user_tags = readthroughs = user_shelves = other_edition_shelves = []
|
user_tags = readthroughs = user_shelves = other_edition_shelves = []
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
|
@ -266,11 +261,6 @@ class Editions(View):
|
||||||
""" list of editions of a book """
|
""" list of editions of a book """
|
||||||
work = get_object_or_404(models.Work, id=book_id)
|
work = get_object_or_404(models.Work, id=book_id)
|
||||||
|
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
if is_api_request(request):
|
if is_api_request(request):
|
||||||
return ActivitypubResponse(work.to_edition_list(**request.GET))
|
return ActivitypubResponse(work.to_edition_list(**request.GET))
|
||||||
filters = {}
|
filters = {}
|
||||||
|
@ -285,7 +275,7 @@ class Editions(View):
|
||||||
|
|
||||||
paginated = Paginator(editions.filter(**filters).all(), PAGE_LENGTH)
|
paginated = Paginator(editions.filter(**filters).all(), PAGE_LENGTH)
|
||||||
data = {
|
data = {
|
||||||
"editions": paginated.get_page(page),
|
"editions": paginated.get_page(request.GET.get("page")),
|
||||||
"work": work,
|
"work": work,
|
||||||
"languages": languages,
|
"languages": languages,
|
||||||
"formats": set(
|
"formats": set(
|
||||||
|
|
|
@ -15,12 +15,6 @@ class Directory(View):
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
""" lets see your cute faces """
|
""" lets see your cute faces """
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
# filters
|
|
||||||
filters = {}
|
filters = {}
|
||||||
software = request.GET.get("software")
|
software = request.GET.get("software")
|
||||||
if not software or software == "bookwyrm":
|
if not software or software == "bookwyrm":
|
||||||
|
@ -39,7 +33,7 @@ class Directory(View):
|
||||||
paginated = Paginator(users, 12)
|
paginated = Paginator(users, 12)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"users": paginated.get_page(page),
|
"users": paginated.get_page(request.GET.get("page")),
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "directory/directory.html", data)
|
return TemplateResponse(request, "directory/directory.html", data)
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,6 @@ class Federation(View):
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
""" list of servers """
|
""" list of servers """
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
servers = models.FederatedServer.objects
|
servers = models.FederatedServer.objects
|
||||||
|
|
||||||
sort = request.GET.get("sort")
|
sort = request.GET.get("sort")
|
||||||
|
@ -40,7 +35,7 @@ class Federation(View):
|
||||||
paginated = Paginator(servers, PAGE_LENGTH)
|
paginated = Paginator(servers, PAGE_LENGTH)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"servers": paginated.get_page(page),
|
"servers": paginated.get_page(request.GET.get("page")),
|
||||||
"sort": sort,
|
"sort": sort,
|
||||||
"form": forms.ServerForm(),
|
"form": forms.ServerForm(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,6 @@ class Feed(View):
|
||||||
|
|
||||||
def get(self, request, tab):
|
def get(self, request, tab):
|
||||||
""" user's homepage with activity feed """
|
""" user's homepage with activity feed """
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
if not tab in STREAMS:
|
if not tab in STREAMS:
|
||||||
tab = "home"
|
tab = "home"
|
||||||
|
|
||||||
|
@ -39,7 +34,7 @@ class Feed(View):
|
||||||
**feed_page_data(request.user),
|
**feed_page_data(request.user),
|
||||||
**{
|
**{
|
||||||
"user": request.user,
|
"user": request.user,
|
||||||
"activities": paginated.get_page(page),
|
"activities": paginated.get_page(request.GET.get("page")),
|
||||||
"suggested_users": suggested_users,
|
"suggested_users": suggested_users,
|
||||||
"tab": tab,
|
"tab": tab,
|
||||||
"goal_form": forms.GoalForm(),
|
"goal_form": forms.GoalForm(),
|
||||||
|
@ -55,11 +50,6 @@ class DirectMessage(View):
|
||||||
|
|
||||||
def get(self, request, username=None):
|
def get(self, request, username=None):
|
||||||
""" like a feed but for dms only """
|
""" like a feed but for dms only """
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
# remove fancy subclasses of status, keep just good ol' notes
|
# remove fancy subclasses of status, keep just good ol' notes
|
||||||
queryset = models.Status.objects.filter(
|
queryset = models.Status.objects.filter(
|
||||||
review__isnull=True,
|
review__isnull=True,
|
||||||
|
@ -82,13 +72,12 @@ class DirectMessage(View):
|
||||||
).order_by("-published_date")
|
).order_by("-published_date")
|
||||||
|
|
||||||
paginated = Paginator(activities, PAGE_LENGTH)
|
paginated = Paginator(activities, PAGE_LENGTH)
|
||||||
activity_page = paginated.get_page(page)
|
|
||||||
data = {
|
data = {
|
||||||
**feed_page_data(request.user),
|
**feed_page_data(request.user),
|
||||||
**{
|
**{
|
||||||
"user": request.user,
|
"user": request.user,
|
||||||
"partner": user,
|
"partner": user,
|
||||||
"activities": activity_page,
|
"activities": paginated.get_page(request.GET.get("page")),
|
||||||
"path": "/direct-messages",
|
"path": "/direct-messages",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -174,7 +163,7 @@ def get_suggested_books(user, max_books=5):
|
||||||
)
|
)
|
||||||
shelf = user.shelf_set.get(identifier=preset)
|
shelf = user.shelf_set.get(identifier=preset)
|
||||||
|
|
||||||
shelf_books = shelf.shelfbook_set.order_by("-updated_date").all()[:limit]
|
shelf_books = shelf.shelfbook_set.order_by("-updated_date")[:limit]
|
||||||
if not shelf_books:
|
if not shelf_books:
|
||||||
continue
|
continue
|
||||||
shelf_preview = {
|
shelf_preview = {
|
||||||
|
|
|
@ -30,11 +30,6 @@ class ManageInvites(View):
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
""" invite management page """
|
""" invite management page """
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
paginated = Paginator(
|
paginated = Paginator(
|
||||||
models.SiteInvite.objects.filter(user=request.user).order_by(
|
models.SiteInvite.objects.filter(user=request.user).order_by(
|
||||||
"-created_date"
|
"-created_date"
|
||||||
|
@ -43,7 +38,7 @@ class ManageInvites(View):
|
||||||
)
|
)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"invites": paginated.get_page(page),
|
"invites": paginated.get_page(request.GET.get("page")),
|
||||||
"form": forms.CreateInviteForm(),
|
"form": forms.CreateInviteForm(),
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "settings/manage_invites.html", data)
|
return TemplateResponse(request, "settings/manage_invites.html", data)
|
||||||
|
@ -93,11 +88,6 @@ class ManageInviteRequests(View):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
""" view a list of requests """
|
""" view a list of requests """
|
||||||
ignored = request.GET.get("ignored", False)
|
ignored = request.GET.get("ignored", False)
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
sort = request.GET.get("sort")
|
sort = request.GET.get("sort")
|
||||||
sort_fields = [
|
sort_fields = [
|
||||||
"created_date",
|
"created_date",
|
||||||
|
@ -136,7 +126,7 @@ class ManageInviteRequests(View):
|
||||||
data = {
|
data = {
|
||||||
"ignored": ignored,
|
"ignored": ignored,
|
||||||
"count": paginated.count,
|
"count": paginated.count,
|
||||||
"requests": paginated.get_page(page),
|
"requests": paginated.get_page(request.GET.get("page")),
|
||||||
"sort": sort,
|
"sort": sort,
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "settings/manage_invite_requests.html", data)
|
return TemplateResponse(request, "settings/manage_invite_requests.html", data)
|
||||||
|
|
|
@ -26,11 +26,6 @@ class Lists(View):
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
""" display a book list """
|
""" display a book list """
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
# hide lists with no approved books
|
# hide lists with no approved books
|
||||||
lists = (
|
lists = (
|
||||||
models.List.objects.annotate(
|
models.List.objects.annotate(
|
||||||
|
@ -47,7 +42,7 @@ class Lists(View):
|
||||||
|
|
||||||
paginated = Paginator(lists, 12)
|
paginated = Paginator(lists, 12)
|
||||||
data = {
|
data = {
|
||||||
"lists": paginated.get_page(page),
|
"lists": paginated.get_page(request.GET.get("page")),
|
||||||
"list_form": forms.ListForm(),
|
"list_form": forms.ListForm(),
|
||||||
"path": "/list",
|
"path": "/list",
|
||||||
}
|
}
|
||||||
|
@ -70,19 +65,15 @@ class UserLists(View):
|
||||||
|
|
||||||
def get(self, request, username):
|
def get(self, request, username):
|
||||||
""" display a book list """
|
""" display a book list """
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
user = get_user_from_username(request.user, username)
|
user = get_user_from_username(request.user, username)
|
||||||
lists = models.List.objects.filter(user=user).all()
|
lists = models.List.objects.filter(user=user)
|
||||||
lists = privacy_filter(request.user, lists)
|
lists = privacy_filter(request.user, lists)
|
||||||
paginated = Paginator(lists, 12)
|
paginated = Paginator(lists, 12)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"user": user,
|
"user": user,
|
||||||
"is_self": request.user.id == user.id,
|
"is_self": request.user.id == user.id,
|
||||||
"lists": paginated.get_page(page),
|
"lists": paginated.get_page(request.GET.get("page")),
|
||||||
"list_form": forms.ListForm(),
|
"list_form": forms.ListForm(),
|
||||||
"path": user.local_path + "/lists",
|
"path": user.local_path + "/lists",
|
||||||
}
|
}
|
||||||
|
@ -114,8 +105,6 @@ class List(View):
|
||||||
if direction not in ("ascending", "descending"):
|
if direction not in ("ascending", "descending"):
|
||||||
direction = "ascending"
|
direction = "ascending"
|
||||||
|
|
||||||
page = request.GET.get("page", 1)
|
|
||||||
|
|
||||||
internal_sort_by = {
|
internal_sort_by = {
|
||||||
"order": "order",
|
"order": "order",
|
||||||
"title": "book__title",
|
"title": "book__title",
|
||||||
|
@ -163,7 +152,7 @@ class List(View):
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"list": book_list,
|
"list": book_list,
|
||||||
"items": paginated.get_page(page),
|
"items": paginated.get_page(request.GET.get("page")),
|
||||||
"pending_count": book_list.listitem_set.filter(approved=False).count(),
|
"pending_count": book_list.listitem_set.filter(approved=False).count(),
|
||||||
"suggested_books": suggestions,
|
"suggested_books": suggestions,
|
||||||
"list_form": forms.ListForm(instance=book_list),
|
"list_form": forms.ListForm(instance=book_list),
|
||||||
|
@ -212,7 +201,8 @@ class Curate(View):
|
||||||
suggestion = get_object_or_404(models.ListItem, id=request.POST.get("item"))
|
suggestion = get_object_or_404(models.ListItem, id=request.POST.get("item"))
|
||||||
approved = request.POST.get("approved") == "true"
|
approved = request.POST.get("approved") == "true"
|
||||||
if approved:
|
if approved:
|
||||||
# update the book and set it to be the last in the order of approved books, before any pending books
|
# update the book and set it to be the last in the order of approved books,
|
||||||
|
# before any pending books
|
||||||
suggestion.approved = True
|
suggestion.approved = True
|
||||||
order_max = (
|
order_max = (
|
||||||
book_list.listitem_set.filter(approved=True).aggregate(Max("order"))[
|
book_list.listitem_set.filter(approved=True).aggregate(Max("order"))[
|
||||||
|
@ -241,7 +231,7 @@ def add_book(request):
|
||||||
# do you have permission to add to the list?
|
# do you have permission to add to the list?
|
||||||
try:
|
try:
|
||||||
if request.user == book_list.user or book_list.curation == "open":
|
if request.user == book_list.user or book_list.curation == "open":
|
||||||
# add the book at the latest order of approved books, before any pending books
|
# add the book at the latest order of approved books, before pending books
|
||||||
order_max = (
|
order_max = (
|
||||||
book_list.listitem_set.filter(approved=True).aggregate(Max("order"))[
|
book_list.listitem_set.filter(approved=True).aggregate(Max("order"))[
|
||||||
"order__max"
|
"order__max"
|
||||||
|
@ -327,7 +317,7 @@ def set_book_position(request, list_item_id):
|
||||||
original_order = list_item.order
|
original_order = list_item.order
|
||||||
if original_order == int_position:
|
if original_order == int_position:
|
||||||
return HttpResponse(status=204)
|
return HttpResponse(status=204)
|
||||||
elif original_order > int_position:
|
if original_order > int_position:
|
||||||
list_item.order = -1
|
list_item.order = -1
|
||||||
list_item.save()
|
list_item.save()
|
||||||
increment_order_in_reverse(book_list.id, int_position, original_order)
|
increment_order_in_reverse(book_list.id, int_position, original_order)
|
||||||
|
@ -346,6 +336,7 @@ def set_book_position(request, list_item_id):
|
||||||
def increment_order_in_reverse(
|
def increment_order_in_reverse(
|
||||||
book_list_id: int, start: int, end: Optional[int] = None
|
book_list_id: int, start: int, end: Optional[int] = None
|
||||||
):
|
):
|
||||||
|
""" increase the order nu,ber for every item in a list """
|
||||||
try:
|
try:
|
||||||
book_list = models.List.objects.get(id=book_list_id)
|
book_list = models.List.objects.get(id=book_list_id)
|
||||||
except models.List.DoesNotExist:
|
except models.List.DoesNotExist:
|
||||||
|
@ -361,6 +352,7 @@ def increment_order_in_reverse(
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def decrement_order(book_list_id, start, end):
|
def decrement_order(book_list_id, start, end):
|
||||||
|
""" decrement the order value for every item in a list """
|
||||||
try:
|
try:
|
||||||
book_list = models.List.objects.get(id=book_list_id)
|
book_list = models.List.objects.get(id=book_list_id)
|
||||||
except models.List.DoesNotExist:
|
except models.List.DoesNotExist:
|
||||||
|
@ -375,10 +367,11 @@ def decrement_order(book_list_id, start, end):
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def normalize_book_list_ordering(book_list_id, start=0, add_offset=0):
|
def normalize_book_list_ordering(book_list_id, start=0, add_offset=0):
|
||||||
|
""" gives each book in a list the proper sequential order number """
|
||||||
try:
|
try:
|
||||||
book_list = models.List.objects.get(id=book_list_id)
|
book_list = models.List.objects.get(id=book_list_id)
|
||||||
except models.List.DoesNotExist:
|
except models.List.DoesNotExist:
|
||||||
return HttpResponseNotFound()
|
return
|
||||||
items = book_list.listitem_set.filter(order__gt=start).order_by("order")
|
items = book_list.listitem_set.filter(order__gt=start).order_by("order")
|
||||||
for i, item in enumerate(items, start):
|
for i, item in enumerate(items, start):
|
||||||
effective_order = i + add_offset
|
effective_order = i + add_offset
|
||||||
|
|
|
@ -145,6 +145,7 @@ def create_readthrough(request):
|
||||||
|
|
||||||
|
|
||||||
def load_date_in_user_tz_as_utc(date_str: str, user: models.User) -> datetime:
|
def load_date_in_user_tz_as_utc(date_str: str, user: models.User) -> datetime:
|
||||||
|
""" ensures that data is stored consistently in the UTC timezone """
|
||||||
user_tz = dateutil.tz.gettz(user.preferred_timezone)
|
user_tz = dateutil.tz.gettz(user.preferred_timezone)
|
||||||
start_date = dateutil.parser.parse(date_str, ignoretz=True)
|
start_date = dateutil.parser.parse(date_str, ignoretz=True)
|
||||||
return start_date.replace(tzinfo=user_tz).astimezone(dateutil.tz.UTC)
|
return start_date.replace(tzinfo=user_tz).astimezone(dateutil.tz.UTC)
|
||||||
|
|
|
@ -30,11 +30,6 @@ class Shelf(View):
|
||||||
except models.User.DoesNotExist:
|
except models.User.DoesNotExist:
|
||||||
return HttpResponseNotFound()
|
return HttpResponseNotFound()
|
||||||
|
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
shelves = privacy_filter(request.user, user.shelf_set)
|
shelves = privacy_filter(request.user, user.shelf_set)
|
||||||
|
|
||||||
# get the shelf and make sure the logged in user should be able to see it
|
# get the shelf and make sure the logged in user should be able to see it
|
||||||
|
@ -61,7 +56,7 @@ class Shelf(View):
|
||||||
return ActivitypubResponse(shelf.to_activity(**request.GET))
|
return ActivitypubResponse(shelf.to_activity(**request.GET))
|
||||||
|
|
||||||
paginated = Paginator(
|
paginated = Paginator(
|
||||||
shelf.books.order_by("-updated_date").all(),
|
shelf.books.order_by("-updated_date"),
|
||||||
PAGE_LENGTH,
|
PAGE_LENGTH,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,7 +65,7 @@ class Shelf(View):
|
||||||
"is_self": is_self,
|
"is_self": is_self,
|
||||||
"shelves": shelves.all(),
|
"shelves": shelves.all(),
|
||||||
"shelf": shelf,
|
"shelf": shelf,
|
||||||
"books": paginated.get_page(page),
|
"books": paginated.get_page(request.GET.get("page")),
|
||||||
}
|
}
|
||||||
|
|
||||||
return TemplateResponse(request, "user/shelf.html", data)
|
return TemplateResponse(request, "user/shelf.html", data)
|
||||||
|
|
|
@ -40,11 +40,6 @@ class User(View):
|
||||||
return ActivitypubResponse(user.to_activity())
|
return ActivitypubResponse(user.to_activity())
|
||||||
# otherwise we're at a UI view
|
# otherwise we're at a UI view
|
||||||
|
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
shelf_preview = []
|
shelf_preview = []
|
||||||
|
|
||||||
# only show other shelves that should be visible
|
# only show other shelves that should be visible
|
||||||
|
@ -64,7 +59,7 @@ class User(View):
|
||||||
{
|
{
|
||||||
"name": user_shelf.name,
|
"name": user_shelf.name,
|
||||||
"local_path": user_shelf.local_path,
|
"local_path": user_shelf.local_path,
|
||||||
"books": user_shelf.books.all()[:3],
|
"books": user_shelf.books[:3],
|
||||||
"size": user_shelf.books.count(),
|
"size": user_shelf.books.count(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -87,7 +82,7 @@ class User(View):
|
||||||
"is_self": is_self,
|
"is_self": is_self,
|
||||||
"shelves": shelf_preview,
|
"shelves": shelf_preview,
|
||||||
"shelf_count": shelves.count(),
|
"shelf_count": shelves.count(),
|
||||||
"activities": paginated.get_page(page),
|
"activities": paginated.get_page(request.GET.get("page", 1)),
|
||||||
"goal": goal,
|
"goal": goal,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,6 @@ class UserAdmin(View):
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
""" list of users """
|
""" list of users """
|
||||||
try:
|
|
||||||
page = int(request.GET.get("page", 1))
|
|
||||||
except ValueError:
|
|
||||||
page = 1
|
|
||||||
|
|
||||||
filters = {}
|
filters = {}
|
||||||
server = request.GET.get("server")
|
server = request.GET.get("server")
|
||||||
if server:
|
if server:
|
||||||
|
@ -50,7 +45,7 @@ class UserAdmin(View):
|
||||||
|
|
||||||
paginated = Paginator(users, PAGE_LENGTH)
|
paginated = Paginator(users, PAGE_LENGTH)
|
||||||
data = {
|
data = {
|
||||||
"users": paginated.get_page(page),
|
"users": paginated.get_page(request.GET.get("page")),
|
||||||
"sort": sort,
|
"sort": sort,
|
||||||
"server": server,
|
"server": server,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue