Fix templates & remove debug

This commit is contained in:
László Károlyi 2024-09-13 02:48:52 +02:00
parent 4b26c8707a
commit 5b591e8069
Signed by: karolyi
GPG key ID: 2DCAF25E55735BFE
5 changed files with 14 additions and 20 deletions

View file

@ -26,8 +26,8 @@ class _TemplateGetter(object):
def setup(self, backend: KtoolsJinjaBackend, cache_enabled: bool):
self.k_jinja_backend = backend
self.cache_enabled = cache_enabled or True
if cache_enabled or True:
self.cache_enabled = cache_enabled
if cache_enabled:
self.hits = self.misses = 0
self.cached = dict[str, Template]()

View file

@ -3,15 +3,7 @@
{%- if widget.value != None %}
value="{{ widget.value|e }}"
{%- endif %}
{% if _k_boundfield.form.is_bound %}
{% if _k_boundfield.errors %}
{{- attr_class(widget, 'form-check-input is-invalid') -}}
{% else %}
{{- attr_class(widget, 'form-check-input is-valid') -}}
{% endif %}
{% else %}
{{- attr_class(widget, 'form-check-input') -}}
{% endif %}
{{- attr_class(widget, 'form-check-input') -}}
{% include 'widgets/bootstrap5/floating/attrs-wo-class.html.jinja' %}
placeholder="{{ _k_boundfield.label|e }}">
<label

View file

@ -2,14 +2,16 @@
{% set id = widget.attrs.id %}
<div class="mb-3">
<fieldset data-ktools-field-type="{{ dash_case_convert(name=_k_boundfield.field.widget.__class__.__name__) }}"
{%- if id %}
id="{{ id }}"
{% endif %}
{% if _k_boundfield.form.is_bound and _k_boundfield.errors %}
{{- attr_class(widget, 'form-control is-invalid') -}}
{%- if _k_boundfield.form.is_bound %}
{% if _k_boundfield.errors %}
{{- attr_class(widget, 'form-control is-invalid') -}}
{% else %}
{{- attr_class(widget, 'form-control is-valid') -}}
{% endif %}
{% else %}
{{- attr_class(widget, 'form-control') -}}
{% endif -%}
{% endif %}
{% include 'widgets/bootstrap5/floating/attrs-wo-class.html.jinja' -%}
>
<label class="form-label">
{{ _k_boundfield.label }}

View file

@ -32,6 +32,6 @@ class Fernet(object):
return unpacked
@staticmethod
def extract_timestamp(token: str) -> int | None:
def extract_timestamp(token: str) -> int:
'Return the creation unixtime of the data.'
return _ENCRYPTOR.extract_timestamp(token=token.encode('utf-8'))

View file

@ -52,9 +52,9 @@ class TokenLink(object):
return Fernet.encrypt(data=data)
@cached_property
def created_at(self) -> int | None:
def created_at(self) -> int:
"""
Return the creation unix timestamp of the link or `None` if
Return the creation unix timestamp of the link or raise if
invalid or the tokenlink isn't generated yet.
"""
if 'token' not in vars(self):