Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress error for non-existent page #2044

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions web/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.contrib.auth.models import AnonymousUser
from django.contrib.auth.views import PasswordResetView, redirect_to_login
from django.core.exceptions import PermissionDenied
from django.core.paginator import Paginator
from django.core.paginator import Paginator, EmptyPage
from django.core.validators import URLValidator
from django.db import transaction
from django.db.models import Q
Expand Down Expand Up @@ -2818,7 +2818,11 @@ def as_printable_html(
logger.info(f"Rendering Casebook {casebook.id}, starting from page {page}: serializing to HTML")

paginator = Paginator(top_level_nodes, 1)
page = paginator.page(page)
try:
page = paginator.page(page)
except EmptyPage:
logger.info(f"Page {page} of Casebook {casebook.id} not found")
raise Http404
section = page[0]

node_filter = {} if whole_book else {"ordinals__0": section.ordinals[0]}
Expand Down
Loading