feat(FastAPI): added /requests (get) route

Introduces `aurweb.defaults` and `aurweb.filters`.

`aurweb.filters` is a location developers can put their additional
Jinja2 filters and/or functions. We should slowly move all of our
filters over here, where it makes sense.

`aurweb.defaults` is a new module which hosts some default constants
and utility functions, starting with offsets (O) and per page values
(PP).

As far as the new GET /requests is concerned, we match up here to
PHP's implementation, with some minor improvements:

Improvements:

* PP on this page is now configurable: 50 (default), 100, or 250.
    * Example: `https://localhost:8444/requests?PP=250`

Modifications:

* The pagination is a bit different, but serves the exact same purpose.
* "Last" no longer goes to an empty page.
    * Closes: https://gitlab.archlinux.org/archlinux/aurweb/-/issues/14

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-09-10 13:28:11 -07:00
parent c164abe256
commit 99482f9962
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
11 changed files with 341 additions and 17 deletions

View file

@ -1,6 +1,6 @@
import pytest
from aurweb.templates import register_filter
from aurweb.templates import register_filter, register_function
@register_filter("func")
@ -8,6 +8,11 @@ def func():
pass
@register_function("function")
def function():
pass
def test_register_filter_exists_key_error():
""" Most instances of register_filter are tested through module
imports or template renders, so we only test failures here. """
@ -15,3 +20,12 @@ def test_register_filter_exists_key_error():
@register_filter("func")
def some_func():
pass
def test_register_function_exists_key_error():
""" Most instances of register_filter are tested through module
imports or template renders, so we only test failures here. """
with pytest.raises(KeyError):
@register_function("function")
def some_func():
pass