1
0
Fork 0
mirror of https://github.com/YunoHost/apps.git synced 2024-09-03 20:06:07 +02:00

Fix appgenerator error (#2301)

* appgenerator: Add a red background on fields with error, otherwise there's no clear indication what's wrong ... though there are some other issues, to be investigated further

* appgenerator: more fixes for wtfforms, make it easier to debug form errors
This commit is contained in:
Alexandre Aubin 2024-05-07 19:17:15 +02:00 committed by GitHub
parent 028507dc9b
commit cd5035400c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View file

@ -1,4 +1,5 @@
#### Imports #### Imports
import logging
from io import BytesIO from io import BytesIO
import re import re
import os import os
@ -33,6 +34,7 @@ from wtforms.validators import (
URL, URL,
Length, Length,
) )
from wtforms.fields import HiddenField
# Translations # Translations
from flask_babel import Babel from flask_babel import Babel
@ -49,6 +51,8 @@ from flask_cors import CORS
from urllib import parse from urllib import parse
from secrets import token_urlsafe from secrets import token_urlsafe
logger = logging.getLogger()
#### GLOBAL VARIABLES #### GLOBAL VARIABLES
YOLOGEN_VERSION = "0.10" YOLOGEN_VERSION = "0.10"
GENERATOR_DICT = {"GENERATOR_VERSION": YOLOGEN_VERSION} GENERATOR_DICT = {"GENERATOR_VERSION": YOLOGEN_VERSION}
@ -60,6 +64,12 @@ cors = CORS(app)
environment = j2.Environment(loader=j2.FileSystemLoader("templates/")) environment = j2.Environment(loader=j2.FileSystemLoader("templates/"))
def is_hidden_field_filter(field):
return isinstance(field, HiddenField)
app.jinja_env.globals['bootstrap_is_hidden_field'] = is_hidden_field_filter
# Handle translations # Handle translations
BABEL_TRANSLATION_DIRECTORIES = "translations" BABEL_TRANSLATION_DIRECTORIES = "translations"
@ -683,8 +693,8 @@ def main_form_route():
if request.method == "POST": if request.method == "POST":
if not main_form.validate_on_submit(): if not main_form.validate_on_submit():
print("Form not validated?") logging.error("Form not validated?")
print(main_form.errors) logging.error(main_form.errors)
return render_template( return render_template(
"index.html", "index.html",

View file

@ -102,4 +102,8 @@
.tip { .tip {
@apply italic p-2; @apply italic p-2;
} }
.has-error {
@apply bg-red-200;
}
} }