You've already forked snikket-web-portal
Compare commits
1 Commits
feature/wt
...
feature/va
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20abe4b903 |
@@ -5,5 +5,5 @@ hsluv~=0.0.2
|
|||||||
flask-babel~=1.0
|
flask-babel~=1.0
|
||||||
email-validator~=1.1
|
email-validator~=1.1
|
||||||
environ-config~=20.0
|
environ-config~=20.0
|
||||||
wtforms~=3.0
|
wtforms~=2.3
|
||||||
typing-extensions
|
typing-extensions
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import aiohttp
|
|||||||
import quart.flask_patch
|
import quart.flask_patch
|
||||||
|
|
||||||
import wtforms
|
import wtforms
|
||||||
|
import wtforms.fields.html5
|
||||||
|
|
||||||
from quart import (
|
from quart import (
|
||||||
Blueprint,
|
Blueprint,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import quart.flask_patch # noqa:F401
|
|||||||
from quart import (
|
from quart import (
|
||||||
current_app,
|
current_app,
|
||||||
request,
|
request,
|
||||||
|
g,
|
||||||
)
|
)
|
||||||
|
|
||||||
import flask_babel
|
import flask_babel
|
||||||
@@ -34,6 +35,9 @@ BYTE_UNIT_SCALE_MAP = [
|
|||||||
|
|
||||||
@babel.localeselector # type:ignore
|
@babel.localeselector # type:ignore
|
||||||
def selected_locale() -> str:
|
def selected_locale() -> str:
|
||||||
|
# Needs mypy ignore because this is a free-for-all object and has no
|
||||||
|
# publicly known attributes.
|
||||||
|
g.language_header_accessed = True # type: ignore
|
||||||
selected = request.accept_languages.best_match(
|
selected = request.accept_languages.best_match(
|
||||||
current_app.config['LANGUAGES']
|
current_app.config['LANGUAGES']
|
||||||
) or current_app.config['LANGUAGES'][0]
|
) or current_app.config['LANGUAGES'][0]
|
||||||
@@ -68,6 +72,12 @@ def format_bytes(n: float) -> str:
|
|||||||
return "{} {}".format(n, unit)
|
return "{} {}".format(n, unit)
|
||||||
|
|
||||||
|
|
||||||
|
def add_vary_language_header(resp: quart.Response) -> quart.Response:
|
||||||
|
if getattr(g, "language_header_accessed", False):
|
||||||
|
resp.vary.add("Accept-Language")
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
def init_templating(app: quart.Quart) -> None:
|
def init_templating(app: quart.Quart) -> None:
|
||||||
app.template_filter("repr")(repr)
|
app.template_filter("repr")(repr)
|
||||||
app.template_filter("format_datetime")(flask_babel.format_datetime)
|
app.template_filter("format_datetime")(flask_babel.format_datetime)
|
||||||
@@ -78,6 +88,7 @@ def init_templating(app: quart.Quart) -> None:
|
|||||||
app.template_filter("format_bytes")(format_bytes)
|
app.template_filter("format_bytes")(format_bytes)
|
||||||
app.template_filter("flatten")(flatten)
|
app.template_filter("flatten")(flatten)
|
||||||
app.template_filter("circle_name")(circle_name)
|
app.template_filter("circle_name")(circle_name)
|
||||||
|
app.after_request(add_vary_language_header)
|
||||||
|
|
||||||
|
|
||||||
def generate_error_id() -> str:
|
def generate_error_id() -> str:
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ bp = quart.Blueprint("main", __name__)
|
|||||||
|
|
||||||
|
|
||||||
class LoginForm(BaseForm):
|
class LoginForm(BaseForm):
|
||||||
address = wtforms.StringField(
|
address = wtforms.TextField(
|
||||||
_l("Address"),
|
_l("Address"),
|
||||||
validators=[wtforms.validators.InputRequired()],
|
validators=[wtforms.validators.InputRequired()],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ _ACCESS_MODEL_CHOICES = [
|
|||||||
|
|
||||||
|
|
||||||
class ProfileForm(BaseForm):
|
class ProfileForm(BaseForm):
|
||||||
nickname = wtforms.StringField(
|
nickname = wtforms.TextField(
|
||||||
_l("Display name"),
|
_l("Display name"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user