Renamed PageNoOutOfRangeError to PageNoOutOfRangeException.

This commit is contained in:
依瑪貓 2020-07-07 20:56:01 +08:00
parent 5ff7f444e9
commit df0380362b
2 changed files with 5 additions and 5 deletions

View File

@ -32,7 +32,7 @@ from accounting.utils import PeriodParser
from mia import settings
from mia_core.digest_auth import digest_login_required
from mia_core.utils import UrlBuilder, Pagination, \
PageNoOutOfRangeError
PageNoOutOfRangeException
@require_GET
@ -114,7 +114,7 @@ class BaseReportView(generic.ListView):
try:
r = super(BaseReportView, self) \
.get(request, *args, **kwargs)
except PageNoOutOfRangeError:
except PageNoOutOfRangeException:
return HttpResponseRedirect(
str(UrlBuilder(request.get_full_path())
.del_param("page")))

View File

@ -157,15 +157,15 @@ class Pagination:
total_pages = int((count - 1) / self.page_size) + 1
default_page = 1 if not is_reverse else total_pages
if page_no == default_page:
raise PageNoOutOfRangeError()
raise PageNoOutOfRangeException()
self.page_no = page_no \
if page_no is not None \
else default_page
if self.page_no > total_pages:
raise PageNoOutOfRangeError()
raise PageNoOutOfRangeException()
class PageNoOutOfRangeError(Exception):
class PageNoOutOfRangeException(Exception):
"""The error thrown when the specified page number is out of
range.
"""