From 2de03d719e5bf03a3f3c548d52e4e9a7dcbc9787 Mon Sep 17 00:00:00 2001 From: Deimos Date: Fri, 3 Aug 2018 14:06:34 -0600 Subject: [PATCH] PaginatedResults: use id36s for before/after This was previously using regular integer IDs, but it should have been ID36s. --- tildes/tildes/models/pagination.py | 16 +++++++++------- tildes/tildes/templates/topic_listing.jinja2 | 4 ++-- tildes/tildes/templates/user.jinja2 | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tildes/tildes/models/pagination.py b/tildes/tildes/models/pagination.py index 9e47562..cd52d2f 100644 --- a/tildes/tildes/models/pagination.py +++ b/tildes/tildes/models/pagination.py @@ -5,7 +5,7 @@ from typing import Any, Iterator, List, Optional, TypeVar from pyramid.request import Request from sqlalchemy import Column, func, inspect -from tildes.lib.id import id36_to_id +from tildes.lib.id import id_to_id36, id36_to_id from .model_query import ModelQuery @@ -206,17 +206,19 @@ class PaginatedResults: return len(self.results) @property - def next_page_after_id(self) -> int: - """Return "after" ID that should be used to fetch the next page.""" + def next_page_after_id36(self) -> str: + """Return "after" ID36 that should be used to fetch the next page.""" if not self.has_next_page: raise AttributeError - return inspect(self.results[-1]).identity[0] + next_id = inspect(self.results[-1]).identity[0] + return id_to_id36(next_id) @property - def prev_page_before_id(self) -> int: - """Return "before" ID that should be used to fetch the prev page.""" + def prev_page_before_id36(self) -> str: + """Return "before" ID36 that should be used to fetch the prev page.""" if not self.has_prev_page: raise AttributeError - return inspect(self.results[0]).identity[0] + prev_id = inspect(self.results[0]).identity[0] + return id_to_id36(prev_id) diff --git a/tildes/tildes/templates/topic_listing.jinja2 b/tildes/tildes/templates/topic_listing.jinja2 index 2439d8d8..ab4bf51 100644 --- a/tildes/tildes/templates/topic_listing.jinja2 +++ b/tildes/tildes/templates/topic_listing.jinja2 @@ -154,13 +154,13 @@ diff --git a/tildes/tildes/templates/user.jinja2 b/tildes/tildes/templates/user.jinja2 index a043528..b6362fe 100644 --- a/tildes/tildes/templates/user.jinja2 +++ b/tildes/tildes/templates/user.jinja2 @@ -52,13 +52,13 @@