mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
This module includes timezone-based utilities for a FastAPI request. This commit introduces use of the AURTZ cookie within get_request_timezone. This cookie should be set to the user or session's timezone. * `make_context` has been modified to parse the request's timezone and include the "timezone" and "timezones" variables, along with a timezone specified "now" date. + Added `Timezone` attribute to aurweb.testing.requests.Request.user. Signed-off-by: Kevin Morris <kevr@0cost.org>
28 lines
626 B
Python
28 lines
626 B
Python
import aurweb.config
|
|
|
|
|
|
class User:
|
|
""" A fake User model. """
|
|
# Fake columns.
|
|
LangPreference = aurweb.config.get("options", "default_lang")
|
|
Timezone = aurweb.config.get("options", "default_timezone")
|
|
|
|
# A fake authenticated flag.
|
|
authenticated = False
|
|
|
|
def is_authenticated(self):
|
|
return self.authenticated
|
|
|
|
|
|
class Client:
|
|
""" A fake FastAPI Request.client object. """
|
|
# A fake host.
|
|
host = "127.0.0.1"
|
|
|
|
|
|
class Request:
|
|
""" A fake Request object which mimics a FastAPI Request for tests. """
|
|
client = Client()
|
|
cookies = dict()
|
|
headers = dict()
|
|
user = User()
|