forked from Github-Mirrors/canaille
refactor: move templates in a common directory
without this, theming was broken because it needs one single directory for templates.
This commit is contained in:
parent
55993723c7
commit
fe8929d992
75 changed files with 120 additions and 111 deletions
|
@ -85,9 +85,12 @@ def request_is_htmx():
|
|||
|
||||
|
||||
def render_htmx_template(template, htmx_template=None, **kwargs):
|
||||
template = (
|
||||
(htmx_template or f"partial/{template}") if request_is_htmx() else template
|
||||
)
|
||||
if request_is_htmx():
|
||||
if htmx_template:
|
||||
template = htmx_template
|
||||
else:
|
||||
*dirs, file = template.split("/")
|
||||
template = "/".join([*dirs, "partial", file])
|
||||
return render_template(template, **kwargs)
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from . import admin
|
|||
from . import auth
|
||||
from . import groups
|
||||
|
||||
bp = Blueprint("core", __name__, template_folder="../templates")
|
||||
bp = Blueprint("core", __name__)
|
||||
|
||||
bp.register_blueprint(account.bp)
|
||||
bp.register_blueprint(admin.bp)
|
||||
|
|
|
@ -94,7 +94,7 @@ def join():
|
|||
),
|
||||
"success",
|
||||
)
|
||||
return render_template("join.html", form=form)
|
||||
return render_template("core/join.html", form=form)
|
||||
|
||||
payload = RegistrationPayload(
|
||||
creation_date_isoformat=datetime.datetime.now(
|
||||
|
@ -130,13 +130,13 @@ def join():
|
|||
"error",
|
||||
)
|
||||
|
||||
return render_template("join.html", form=form)
|
||||
return render_template("core/join.html", form=form)
|
||||
|
||||
|
||||
@bp.route("/about")
|
||||
def about():
|
||||
version = metadata.version("canaille")
|
||||
return render_template("about.html", version=version)
|
||||
return render_template("core/about.html", version=version)
|
||||
|
||||
|
||||
@bp.route("/users", methods=["GET", "POST"])
|
||||
|
@ -151,7 +151,7 @@ def users(user):
|
|||
abort(404)
|
||||
|
||||
return render_htmx_template(
|
||||
"users.html",
|
||||
"core/users.html",
|
||||
menuitem="users",
|
||||
table_form=table_form,
|
||||
)
|
||||
|
@ -221,7 +221,7 @@ def user_invitation(user):
|
|||
email_sent = send_invitation_mail(form.email.data, registration_url)
|
||||
|
||||
return render_template(
|
||||
"invite.html",
|
||||
"core/invite.html",
|
||||
form=form,
|
||||
menuitems="users",
|
||||
form_validated=form_validated,
|
||||
|
@ -328,7 +328,7 @@ def registration(data=None, hash=None):
|
|||
|
||||
if not request.form or form.form_control():
|
||||
return render_template(
|
||||
"profile_add.html",
|
||||
"core/profile_add.html",
|
||||
form=form,
|
||||
menuitem="users",
|
||||
edited_user=None,
|
||||
|
@ -338,7 +338,7 @@ def registration(data=None, hash=None):
|
|||
if not form.validate():
|
||||
flash(_("User account creation failed."), "error")
|
||||
return render_template(
|
||||
"profile_add.html",
|
||||
"core/profile_add.html",
|
||||
form=form,
|
||||
menuitem="users",
|
||||
edited_user=None,
|
||||
|
@ -421,7 +421,7 @@ def profile_creation(user):
|
|||
|
||||
if not request.form or form.form_control():
|
||||
return render_template(
|
||||
"profile_add.html",
|
||||
"core/profile_add.html",
|
||||
form=form,
|
||||
menuitem="users",
|
||||
edited_user=None,
|
||||
|
@ -431,7 +431,7 @@ def profile_creation(user):
|
|||
if not form.validate():
|
||||
flash(_("User account creation failed."), "error")
|
||||
return render_template(
|
||||
"profile_add.html",
|
||||
"core/profile_add.html",
|
||||
form=form,
|
||||
menuitem="users",
|
||||
edited_user=None,
|
||||
|
@ -505,7 +505,7 @@ def profile_edition_main_form(user, edited_user, emails_readonly):
|
|||
profile_form = build_profile_form(writable_fields, readable_fields)
|
||||
profile_form.process(request_data or None, data=data)
|
||||
profile_form.user = edited_user
|
||||
profile_form.render_field_macro_file = "partial/profile_field.html"
|
||||
profile_form.render_field_macro_file = "core/partial/profile_field.html"
|
||||
profile_form.render_field_extra_context = {
|
||||
"user": user,
|
||||
"edited_user": edited_user,
|
||||
|
@ -611,12 +611,12 @@ def profile_edition(user, edited_user):
|
|||
}
|
||||
|
||||
if not request.form or profile_form.form_control():
|
||||
return render_template("profile_edit.html", **render_context)
|
||||
return render_template("core/profile_edit.html", **render_context)
|
||||
|
||||
if request_is_htmx() or request.form.get("action") == "edit-profile":
|
||||
if not profile_form.validate():
|
||||
flash(_("Profile edition failed."), "error")
|
||||
return render_template("profile_edit.html", **render_context)
|
||||
return render_template("core/profile_edit.html", **render_context)
|
||||
|
||||
profile_edition_main_form_validation(user, edited_user, profile_form)
|
||||
|
||||
|
@ -634,7 +634,7 @@ def profile_edition(user, edited_user):
|
|||
if request.form.get("action") == "add_email":
|
||||
if not emails_form.validate():
|
||||
flash(_("Email addition failed."), "error")
|
||||
return render_template("profile_edit.html", **render_context)
|
||||
return render_template("core/profile_edit.html", **render_context)
|
||||
|
||||
if profile_edition_add_email(user, edited_user, emails_form):
|
||||
flash(
|
||||
|
@ -656,7 +656,7 @@ def profile_edition(user, edited_user):
|
|||
user, edited_user, request.form.get("email_remove")
|
||||
):
|
||||
flash(_("Email deletion failed."), "error")
|
||||
return render_template("profile_edit.html", **render_context)
|
||||
return render_template("core/profile_edit.html", **render_context)
|
||||
|
||||
flash(_("The email have been successfully deleted."), "success")
|
||||
return redirect(
|
||||
|
@ -682,7 +682,9 @@ def profile_settings(user, edited_user):
|
|||
return profile_settings_edit(user, edited_user)
|
||||
|
||||
if request.form.get("action") == "confirm-delete":
|
||||
return render_template("modals/delete-account.html", edited_user=edited_user)
|
||||
return render_template(
|
||||
"core/modals/delete-account.html", edited_user=edited_user
|
||||
)
|
||||
|
||||
if request.form.get("action") == "delete":
|
||||
return profile_delete(user, edited_user)
|
||||
|
@ -729,7 +731,7 @@ def profile_settings(user, edited_user):
|
|||
and current_app.features.has_account_lockability
|
||||
and not edited_user.locked
|
||||
):
|
||||
return render_template("modals/lock-account.html", edited_user=edited_user)
|
||||
return render_template("core/modals/lock-account.html", edited_user=edited_user)
|
||||
|
||||
if (
|
||||
request.form.get("action") == "lock"
|
||||
|
@ -757,7 +759,7 @@ def profile_settings(user, edited_user):
|
|||
request.form.get("action") == "confirm-reset-otp"
|
||||
and current_app.features.has_otp
|
||||
):
|
||||
return render_template("modals/reset-otp.html", edited_user=edited_user)
|
||||
return render_template("core/modals/reset-otp.html", edited_user=edited_user)
|
||||
|
||||
if request.form.get("action") == "reset-otp" and current_app.features.has_otp:
|
||||
flash(_("One-time password authentication has been reset"), "success")
|
||||
|
@ -825,7 +827,7 @@ def profile_settings_edit(editor, edited_user):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"profile_settings.html",
|
||||
"core/profile_settings.html",
|
||||
form=form,
|
||||
menuitem=menuitem,
|
||||
edited_user=edited_user,
|
||||
|
|
|
@ -43,7 +43,7 @@ def mail_index(user):
|
|||
else:
|
||||
flash(_("The test mail has not been sent correctly"), "error")
|
||||
|
||||
return render_template("mails/admin.html", form=form, menuitem="admin")
|
||||
return render_template("core/mails/admin.html", form=form, menuitem="admin")
|
||||
|
||||
|
||||
@bp.route("/mail/test.html")
|
||||
|
@ -51,7 +51,7 @@ def mail_index(user):
|
|||
def test_html(user):
|
||||
base_url = url_for("core.account.index", _external=True)
|
||||
return render_template(
|
||||
"mails/test.html",
|
||||
"core/mails/test.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
logo=current_app.config["CANAILLE"]["LOGO"],
|
||||
|
@ -66,7 +66,7 @@ def test_html(user):
|
|||
def test_txt(user):
|
||||
base_url = url_for("core.account.index", _external=True)
|
||||
return render_template(
|
||||
"mails/test.txt",
|
||||
"core/mails/test.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=current_app.config.get("SERVER_NAME", base_url),
|
||||
)
|
||||
|
@ -87,7 +87,7 @@ def password_init_html(user):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/firstlogin.html",
|
||||
"core/mails/firstlogin.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
reset_url=reset_url,
|
||||
|
@ -110,7 +110,7 @@ def password_init_txt(user):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/firstlogin.txt",
|
||||
"core/mails/firstlogin.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=current_app.config.get("SERVER_NAME", base_url),
|
||||
reset_url=reset_url,
|
||||
|
@ -132,7 +132,7 @@ def password_reset_html(user):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/reset.html",
|
||||
"core/mails/reset.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
reset_url=reset_url,
|
||||
|
@ -155,7 +155,7 @@ def password_reset_txt(user):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/reset.txt",
|
||||
"core/mails/reset.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=current_app.config.get("SERVER_NAME", base_url),
|
||||
reset_url=reset_url,
|
||||
|
@ -174,7 +174,7 @@ def invitation_html(user, identifier, email):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/invitation.html",
|
||||
"core/mails/invitation.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
registration_url=registration_url,
|
||||
|
@ -197,7 +197,7 @@ def invitation_txt(user, identifier, email):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/invitation.txt",
|
||||
"core/mails/invitation.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
registration_url=registration_url,
|
||||
|
@ -216,7 +216,7 @@ def email_confirmation_html(user, identifier, email):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/email-confirmation.html",
|
||||
"core/mails/email-confirmation.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
confirmation_url=email_confirmation_url,
|
||||
|
@ -239,7 +239,7 @@ def email_confirmation_txt(user, identifier, email):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/email-confirmation.txt",
|
||||
"core/mails/email-confirmation.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
confirmation_url=email_confirmation_url,
|
||||
|
@ -258,7 +258,7 @@ def registration_html(user, email):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/registration.html",
|
||||
"core/mails/registration.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
registration_url=registration_url,
|
||||
|
@ -281,7 +281,7 @@ def registration_txt(user, email):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"mails/registration.txt",
|
||||
"core/mails/registration.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
registration_url=registration_url,
|
||||
|
@ -298,7 +298,7 @@ def compromised_password_check_failure_html(user):
|
|||
user_email = "<USER EMAIL>"
|
||||
|
||||
return render_template(
|
||||
"mails/compromised_password_check_failure.html",
|
||||
"core/mails/compromised_password_check_failure.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
user_name=user_name,
|
||||
|
@ -322,7 +322,7 @@ def compromised_password_check_failure_txt(user):
|
|||
user_email = "<USER EMAIL>"
|
||||
|
||||
return render_template(
|
||||
"mails/compromised_password_check_failure.txt",
|
||||
"core/mails/compromised_password_check_failure.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
user_name=user_name,
|
||||
|
@ -339,7 +339,7 @@ def email_otp_html(user):
|
|||
otp = "000000"
|
||||
|
||||
return render_template(
|
||||
"mails/email_otp.html",
|
||||
"core/mails/email_otp.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
otp=otp,
|
||||
|
@ -357,7 +357,7 @@ def email_otp_txt(user):
|
|||
otp = "000000"
|
||||
|
||||
return render_template(
|
||||
"mails/email_otp.txt",
|
||||
"core/mails/email_otp.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
otp=otp,
|
||||
|
|
|
@ -49,11 +49,11 @@ def login():
|
|||
)
|
||||
|
||||
form = LoginForm(request.form or None)
|
||||
form.render_field_macro_file = "partial/login_field.html"
|
||||
form.render_field_macro_file = "core/partial/login_field.html"
|
||||
form["login"].render_kw["placeholder"] = Backend.instance.login_placeholder()
|
||||
|
||||
if not request.form or form.form_control():
|
||||
return render_template("login.html", form=form)
|
||||
return render_template("core/login.html", form=form)
|
||||
|
||||
user = Backend.instance.get_user_from_login(form.login.data)
|
||||
if user and not user.has_password() and current_app.features.has_smtp:
|
||||
|
@ -62,7 +62,7 @@ def login():
|
|||
if not form.validate():
|
||||
logout_user()
|
||||
flash(_("Login failed, please check your information"), "error")
|
||||
return render_template("login.html", form=form)
|
||||
return render_template("core/login.html", form=form)
|
||||
|
||||
session["attempt_login"] = form.login.data
|
||||
return redirect(url_for("core.auth.password"))
|
||||
|
@ -80,11 +80,11 @@ def password():
|
|||
return redirect(url_for("core.auth.login"))
|
||||
|
||||
form = PasswordForm(request.form or None)
|
||||
form.render_field_macro_file = "partial/login_field.html"
|
||||
form.render_field_macro_file = "core/partial/login_field.html"
|
||||
|
||||
if not request.form or form.form_control():
|
||||
return render_template(
|
||||
"password.html", form=form, username=session["attempt_login"]
|
||||
"core/password.html", form=form, username=session["attempt_login"]
|
||||
)
|
||||
|
||||
user = Backend.instance.get_user_from_login(session["attempt_login"])
|
||||
|
@ -95,7 +95,7 @@ def password():
|
|||
logout_user()
|
||||
flash(_("Login failed, please check your information"), "error")
|
||||
return render_template(
|
||||
"password.html", form=form, username=session["attempt_login"]
|
||||
"core/password.html", form=form, username=session["attempt_login"]
|
||||
)
|
||||
|
||||
success, message = Backend.instance.check_user_password(user, form.password.data)
|
||||
|
@ -107,7 +107,7 @@ def password():
|
|||
)
|
||||
flash(message or _("Login failed, please check your information"), "error")
|
||||
return render_template(
|
||||
"password.html", form=form, username=session["attempt_login"]
|
||||
"core/password.html", form=form, username=session["attempt_login"]
|
||||
)
|
||||
|
||||
otp_methods = []
|
||||
|
@ -165,7 +165,7 @@ def firstlogin(user):
|
|||
|
||||
form = FirstLoginForm(request.form or None)
|
||||
if not request.form:
|
||||
return render_template("firstlogin.html", form=form, user=user)
|
||||
return render_template("core/firstlogin.html", form=form, user=user)
|
||||
|
||||
form.validate()
|
||||
|
||||
|
@ -182,7 +182,7 @@ def firstlogin(user):
|
|||
else:
|
||||
flash(_("Could not send the password initialization email"), "error")
|
||||
|
||||
return render_template("firstlogin.html", form=form)
|
||||
return render_template("core/firstlogin.html", form=form)
|
||||
|
||||
|
||||
@bp.route("/reset", methods=["GET", "POST"])
|
||||
|
@ -193,11 +193,11 @@ def forgotten():
|
|||
|
||||
form = ForgottenPasswordForm(request.form)
|
||||
if not request.form:
|
||||
return render_template("forgotten-password.html", form=form)
|
||||
return render_template("core/forgotten-password.html", form=form)
|
||||
|
||||
if not form.validate():
|
||||
flash(_("Could not send the password reset link."), "error")
|
||||
return render_template("forgotten-password.html", form=form)
|
||||
return render_template("core/forgotten-password.html", form=form)
|
||||
|
||||
user = Backend.instance.get_user_from_login(form.login.data)
|
||||
success_message = _(
|
||||
|
@ -208,7 +208,7 @@ def forgotten():
|
|||
not user or not user.can_edit_self
|
||||
):
|
||||
flash(success_message, "success")
|
||||
return render_template("forgotten-password.html", form=form)
|
||||
return render_template("core/forgotten-password.html", form=form)
|
||||
|
||||
if not user.can_edit_self:
|
||||
flash(
|
||||
|
@ -219,7 +219,7 @@ def forgotten():
|
|||
),
|
||||
"error",
|
||||
)
|
||||
return render_template("forgotten-password.html", form=form)
|
||||
return render_template("core/forgotten-password.html", form=form)
|
||||
|
||||
request_ip = request.remote_addr or "unknown IP"
|
||||
success = True
|
||||
|
@ -238,7 +238,7 @@ def forgotten():
|
|||
"error",
|
||||
)
|
||||
|
||||
return render_template("forgotten-password.html", form=form)
|
||||
return render_template("core/forgotten-password.html", form=form)
|
||||
|
||||
|
||||
@bp.route("/reset/<user:user>/<hash>", methods=["GET", "POST"])
|
||||
|
@ -274,7 +274,7 @@ def reset(user, hash):
|
|||
)
|
||||
)
|
||||
|
||||
return render_template("reset-password.html", form=form, user=user, hash=hash)
|
||||
return render_template("core/reset-password.html", form=form, user=user, hash=hash)
|
||||
|
||||
|
||||
@bp.route("/setup-2fa")
|
||||
|
@ -298,7 +298,7 @@ def setup_two_factor_auth():
|
|||
uri = user.get_otp_authentication_setup_uri()
|
||||
base64_qr_image = get_b64encoded_qr_image(uri)
|
||||
return render_template(
|
||||
"setup-2fa.html",
|
||||
"core/setup-2fa.html",
|
||||
secret=user.secret_token,
|
||||
qr_image=base64_qr_image,
|
||||
username=user.user_name,
|
||||
|
@ -331,11 +331,11 @@ def verify_two_factor_auth():
|
|||
abort(404)
|
||||
|
||||
form = TwoFactorForm(request.form or None)
|
||||
form.render_field_macro_file = "partial/login_field.html"
|
||||
form.render_field_macro_file = "core/partial/login_field.html"
|
||||
|
||||
if not request.form or form.form_control():
|
||||
return render_template(
|
||||
"verify-2fa.html",
|
||||
"core/verify-2fa.html",
|
||||
form=form,
|
||||
username=session["attempt_login_with_correct_password"],
|
||||
method=current_otp_method,
|
||||
|
|
|
@ -27,7 +27,9 @@ def groups(user):
|
|||
if request.form and request.form.get("page") and not table_form.validate():
|
||||
abort(404)
|
||||
|
||||
return render_htmx_template("groups.html", menuitem="groups", table_form=table_form)
|
||||
return render_htmx_template(
|
||||
"core/groups.html", menuitem="groups", table_form=table_form
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/add", methods=("GET", "POST"))
|
||||
|
@ -54,7 +56,7 @@ def create_group(user):
|
|||
return redirect(url_for("core.groups.group", group=group))
|
||||
|
||||
return render_template(
|
||||
"group.html", menuitem="groups", form=form, edited_group=None, members=None
|
||||
"core/group.html", menuitem="groups", form=form, edited_group=None, members=None
|
||||
)
|
||||
|
||||
|
||||
|
@ -69,7 +71,7 @@ def group(user, group):
|
|||
return edit_group(group)
|
||||
|
||||
if request.form.get("action") == "confirm-delete":
|
||||
return render_template("modals/delete-group.html", group=group)
|
||||
return render_template("core/modals/delete-group.html", group=group)
|
||||
|
||||
if request.form.get("action") == "delete":
|
||||
return delete_group(group)
|
||||
|
@ -116,8 +118,8 @@ def edit_group(group):
|
|||
flash(_("Group edition failed."), "error")
|
||||
|
||||
return render_htmx_template(
|
||||
"group.html",
|
||||
"partial/group-members.html",
|
||||
"core/group.html",
|
||||
"core/partial/group-members.html",
|
||||
form=form,
|
||||
menuitem="groups",
|
||||
edited_group=group,
|
||||
|
@ -137,7 +139,7 @@ def delete_member(group):
|
|||
|
||||
elif request.form.get("action") == "confirm-remove-member":
|
||||
return render_template(
|
||||
"modals/remove-group-member.html", group=group, form=form
|
||||
"core/modals/remove-group-member.html", group=group, form=form
|
||||
)
|
||||
|
||||
else:
|
||||
|
|
|
@ -16,12 +16,12 @@ def send_test_mail(email):
|
|||
website_name=current_app.config["CANAILLE"]["NAME"]
|
||||
)
|
||||
text_body = render_template(
|
||||
"mails/test.txt",
|
||||
"core/mails/test.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
)
|
||||
html_body = render_template(
|
||||
"mails/test.html",
|
||||
"core/mails/test.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
logo=f"cid:{logo_cid[1:-1]}" if logo_cid else None,
|
||||
|
@ -55,13 +55,13 @@ def send_password_reset_mail(user, mail):
|
|||
website_name=current_app.config["CANAILLE"]["NAME"]
|
||||
)
|
||||
text_body = render_template(
|
||||
"mails/reset.txt",
|
||||
"core/mails/reset.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
reset_url=reset_url,
|
||||
)
|
||||
html_body = render_template(
|
||||
"mails/reset.html",
|
||||
"core/mails/reset.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
reset_url=reset_url,
|
||||
|
@ -96,13 +96,13 @@ def send_password_initialization_mail(user, email):
|
|||
website_name=current_app.config["CANAILLE"]["NAME"]
|
||||
)
|
||||
text_body = render_template(
|
||||
"mails/firstlogin.txt",
|
||||
"core/mails/firstlogin.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
reset_url=reset_url,
|
||||
)
|
||||
html_body = render_template(
|
||||
"mails/firstlogin.html",
|
||||
"core/mails/firstlogin.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
reset_url=reset_url,
|
||||
|
@ -127,13 +127,13 @@ def send_invitation_mail(email, registration_url):
|
|||
website_name=current_app.config["CANAILLE"]["NAME"]
|
||||
)
|
||||
text_body = render_template(
|
||||
"mails/invitation.txt",
|
||||
"core/mails/invitation.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
registration_url=registration_url,
|
||||
)
|
||||
html_body = render_template(
|
||||
"mails/invitation.html",
|
||||
"core/mails/invitation.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
registration_url=registration_url,
|
||||
|
@ -158,13 +158,13 @@ def send_confirmation_email(email, confirmation_url):
|
|||
website_name=current_app.config["CANAILLE"]["NAME"]
|
||||
)
|
||||
text_body = render_template(
|
||||
"mails/email-confirmation.txt",
|
||||
"core/mails/email-confirmation.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
confirmation_url=confirmation_url,
|
||||
)
|
||||
html_body = render_template(
|
||||
"mails/email-confirmation.html",
|
||||
"core/mails/email-confirmation.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
confirmation_url=confirmation_url,
|
||||
|
@ -189,13 +189,13 @@ def send_registration_mail(email, registration_url):
|
|||
website_name=current_app.config["CANAILLE"]["NAME"]
|
||||
)
|
||||
text_body = render_template(
|
||||
"mails/registration.txt",
|
||||
"core/mails/registration.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
registration_url=registration_url,
|
||||
)
|
||||
html_body = render_template(
|
||||
"mails/registration.html",
|
||||
"core/mails/registration.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
registration_url=registration_url,
|
||||
|
@ -222,7 +222,7 @@ def send_compromised_password_check_failure_mail(
|
|||
website_name=current_app.config["CANAILLE"]["NAME"]
|
||||
)
|
||||
text_body = render_template(
|
||||
"mails/compromised_password_check_failure.txt",
|
||||
"core/mails/compromised_password_check_failure.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
check_password_url=check_password_url,
|
||||
|
@ -231,7 +231,7 @@ def send_compromised_password_check_failure_mail(
|
|||
hashed_password=hashed_password,
|
||||
)
|
||||
html_body = render_template(
|
||||
"mails/compromised_password_check_failure.html",
|
||||
"core/mails/compromised_password_check_failure.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
check_password_url=check_password_url,
|
||||
|
@ -259,13 +259,13 @@ def send_one_time_password_mail(mail, otp):
|
|||
website_name=current_app.config["CANAILLE"]["NAME"]
|
||||
)
|
||||
text_body = render_template(
|
||||
"mails/email_otp.txt",
|
||||
"core/mails/email_otp.txt",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
otp=otp,
|
||||
)
|
||||
html_body = render_template(
|
||||
"mails/email_otp.html",
|
||||
"core/mails/email_otp.html",
|
||||
site_name=current_app.config["CANAILLE"]["NAME"],
|
||||
site_url=base_url,
|
||||
otp=otp,
|
||||
|
|
|
@ -8,7 +8,7 @@ def send_one_time_password_sms(phone_number, otp):
|
|||
website_name = current_app.config["CANAILLE"]["NAME"]
|
||||
|
||||
text_body = render_template(
|
||||
"sms/sms_otp.txt",
|
||||
"core/sms/sms_otp.txt",
|
||||
website_name=website_name,
|
||||
otp=otp,
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ from . import oauth
|
|||
from . import tokens
|
||||
from . import well_known
|
||||
|
||||
bp = Blueprint("oidc", __name__, template_folder="../templates")
|
||||
bp = Blueprint("oidc", __name__)
|
||||
|
||||
bp.register_blueprint(authorizations.bp)
|
||||
bp.register_blueprint(clients.bp)
|
||||
|
|
|
@ -19,7 +19,7 @@ def index(user):
|
|||
abort(404)
|
||||
|
||||
return render_htmx_template(
|
||||
"authorization_list.html",
|
||||
"oidc/authorization_list.html",
|
||||
menuitem="admin",
|
||||
table_form=table_form,
|
||||
)
|
||||
|
@ -29,7 +29,7 @@ def index(user):
|
|||
@permissions_needed("manage_oidc")
|
||||
def view(user, authorization):
|
||||
return render_template(
|
||||
"authorization_view.html",
|
||||
"oidc/authorization_view.html",
|
||||
authorization=authorization,
|
||||
menuitem="admin",
|
||||
)
|
||||
|
|
|
@ -30,7 +30,7 @@ def index(user):
|
|||
abort(404)
|
||||
|
||||
return render_htmx_template(
|
||||
"client_list.html", menuitem="admin", table_form=table_form
|
||||
"oidc/client_list.html", menuitem="admin", table_form=table_form
|
||||
)
|
||||
|
||||
|
||||
|
@ -40,14 +40,14 @@ def add(user):
|
|||
form = ClientAddForm(request.form or None)
|
||||
|
||||
if not request.form or form.form_control():
|
||||
return render_template("client_add.html", form=form, menuitem="admin")
|
||||
return render_template("oidc/client_add.html", form=form, menuitem="admin")
|
||||
|
||||
if not form.validate():
|
||||
flash(
|
||||
_("The client has not been added. Please check your information."),
|
||||
"error",
|
||||
)
|
||||
return render_template("client_add.html", form=form, menuitem="admin")
|
||||
return render_template("oidc/client_add.html", form=form, menuitem="admin")
|
||||
|
||||
client_id = gen_salt(24)
|
||||
client_id_issued_at = datetime.datetime.now(datetime.timezone.utc)
|
||||
|
@ -90,7 +90,7 @@ def add(user):
|
|||
@permissions_needed("manage_oidc")
|
||||
def edit(user, client):
|
||||
if request.form.get("action") == "confirm-delete":
|
||||
return render_template("modals/delete-client.html", client=client)
|
||||
return render_template("oidc/modals/delete-client.html", client=client)
|
||||
|
||||
if request.form and request.form.get("action") == "delete":
|
||||
return client_delete(client)
|
||||
|
@ -110,7 +110,7 @@ def client_edit(client):
|
|||
|
||||
if not request.form or form.form_control():
|
||||
return render_template(
|
||||
"client_edit.html", form=form, client=client, menuitem="admin"
|
||||
"oidc/client_edit.html", form=form, client=client, menuitem="admin"
|
||||
)
|
||||
|
||||
if not form.validate():
|
||||
|
@ -119,7 +119,7 @@ def client_edit(client):
|
|||
"error",
|
||||
)
|
||||
return render_template(
|
||||
"client_edit.html", form=form, client=client, menuitem="admin"
|
||||
"oidc/client_edit.html", form=form, client=client, menuitem="admin"
|
||||
)
|
||||
|
||||
Backend.instance.update(
|
||||
|
|
|
@ -33,7 +33,7 @@ def consents(user):
|
|||
)
|
||||
|
||||
return render_template(
|
||||
"consent_list.html",
|
||||
"oidc/consent_list.html",
|
||||
consents=consents,
|
||||
menuitem="consents",
|
||||
scope_details=SCOPE_DETAILS,
|
||||
|
@ -58,7 +58,7 @@ def pre_consents(user):
|
|||
nb_preconsents = len(preconsented)
|
||||
|
||||
return render_template(
|
||||
"preconsent_list.html",
|
||||
"oidc/preconsent_list.html",
|
||||
menuitem="consents",
|
||||
scope_details=SCOPE_DETAILS,
|
||||
ignored_scopes=["openid"],
|
||||
|
|
|
@ -143,7 +143,7 @@ def authorize_consent(client, user):
|
|||
|
||||
form = AuthorizeForm(request.form or None)
|
||||
return render_template(
|
||||
"authorize.html",
|
||||
"oidc/authorize.html",
|
||||
user=user,
|
||||
grant=grant,
|
||||
client=client,
|
||||
|
@ -307,7 +307,7 @@ def end_session():
|
|||
or (data.get("logout_hint") and data["logout_hint"] != user.user_name)
|
||||
) and not session.get("end_session_confirmation"):
|
||||
session["end_session_data"] = data
|
||||
return render_template("logout.html", form=form, client=client, menu=False)
|
||||
return render_template("oidc/logout.html", form=form, client=client, menu=False)
|
||||
|
||||
if data.get("id_token_hint"):
|
||||
try:
|
||||
|
@ -358,7 +358,9 @@ def end_session():
|
|||
"end_session_confirmation"
|
||||
):
|
||||
session["end_session_data"] = data
|
||||
return render_template("logout.html", form=form, client=client, menu=False)
|
||||
return render_template(
|
||||
"oidc/logout.html", form=form, client=client, menu=False
|
||||
)
|
||||
|
||||
logout_user()
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ def index(user):
|
|||
abort(404)
|
||||
|
||||
return render_htmx_template(
|
||||
"token_list.html", menuitem="admin", table_form=table_form
|
||||
"oidc/token_list.html", menuitem="admin", table_form=table_form
|
||||
)
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ def view(user, token):
|
|||
|
||||
if request.form and form.validate():
|
||||
if request.form.get("action") == "confirm-revoke":
|
||||
return render_template("modals/revoke-token.html", token=token)
|
||||
return render_template("oidc/modals/revoke-token.html", token=token)
|
||||
|
||||
elif request.form.get("action") == "revoke":
|
||||
token.revokation_date = datetime.datetime.now(datetime.timezone.utc)
|
||||
|
@ -53,7 +53,7 @@ def view(user, token):
|
|||
abort(400, f"bad form action: {request.form.get('action')}")
|
||||
|
||||
return render_template(
|
||||
"token_view.html",
|
||||
"oidc/token_view.html",
|
||||
token=token,
|
||||
menuitem="admin",
|
||||
form=form,
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
|
||||
{{ table.search(table_form, "table.users") }}
|
||||
</div>
|
||||
{% include "partial/group-members.html" %}
|
||||
{% include "core/partial/group-members.html" %}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
|
@ -25,5 +25,5 @@
|
|||
</h2>
|
||||
{{ table.search(table_form, "table.groups") }}
|
||||
</div>
|
||||
{% include "partial/groups.html" %}
|
||||
{% include "core/partial/groups.html" %}
|
||||
{% endblock %}
|
|
@ -1,6 +1,6 @@
|
|||
{% extends theme('base.html') %}
|
||||
{% import 'macro/form.html' as fui %}
|
||||
{% import 'partial/profile_field.html' as profile %}
|
||||
{% import 'core/partial/profile_field.html' as profile %}
|
||||
|
||||
{%- block title -%}
|
||||
{%- trans %}User creation{% endtrans -%}
|
|
@ -1,7 +1,7 @@
|
|||
{% extends theme('base.html') %}
|
||||
{% import 'macro/flask.html' as flask %}
|
||||
{% import 'macro/form.html' as fui %}
|
||||
{% import 'partial/login_field.html' as login_field %}
|
||||
{% import 'core/partial/login_field.html' as login_field %}
|
||||
|
||||
{% block container %}
|
||||
<div class="ui container" hx-boost="false">
|
|
@ -1,7 +1,7 @@
|
|||
{% extends theme('base.html') %}
|
||||
{% import 'macro/flask.html' as flask %}
|
||||
{% import 'macro/form.html' as fui %}
|
||||
{% import 'partial/login_field.html' as login_field %}
|
||||
{% import 'core/partial/login_field.html' as login_field %}
|
||||
|
||||
{% block container %}
|
||||
<div class="ui container">
|
|
@ -1,6 +1,6 @@
|
|||
{% extends theme('base.html') %}
|
||||
{% import 'macro/form.html' as fui %}
|
||||
{% import 'partial/profile_field.html' as profile %}
|
||||
{% import 'core/partial/profile_field.html' as profile %}
|
||||
|
||||
{%- block title -%}
|
||||
{%- trans %}User creation{% endtrans -%}
|
|
@ -1,6 +1,6 @@
|
|||
{% extends theme('base.html') %}
|
||||
{% import 'macro/form.html' as fui %}
|
||||
{% import 'partial/profile_field.html' as profile %}
|
||||
{% import 'core/partial/profile_field.html' as profile %}
|
||||
|
||||
{%- block title -%}
|
||||
{% if not edited_user %}
|
|
@ -1,7 +1,7 @@
|
|||
{% extends theme('base.html') %}
|
||||
{% import 'macro/flask.html' as flask %}
|
||||
{% import 'macro/form.html' as fui %}
|
||||
{% import 'partial/login_field.html' as login_field %}
|
||||
{% import 'core/partial/login_field.html' as login_field %}
|
||||
|
||||
{% block container %}
|
||||
<div class="ui container">
|
|
@ -32,5 +32,5 @@
|
|||
|
||||
{{ table.search(table_form, "table.users") }}
|
||||
</div>
|
||||
{% include "partial/users.html" %}
|
||||
{% include "core/partial/users.html" %}
|
||||
{% endblock %}
|
|
@ -1,7 +1,7 @@
|
|||
{% extends theme('base.html') %}
|
||||
{% import 'macro/flask.html' as flask %}
|
||||
{% import 'macro/form.html' as fui %}
|
||||
{% import 'partial/login_field.html' as login_field %}
|
||||
{% import 'core/partial/login_field.html' as login_field %}
|
||||
|
||||
{% block container %}
|
||||
<div class="ui container">
|
|
@ -38,5 +38,5 @@
|
|||
|
||||
{{ table.search(table_form, "table.codes") }}
|
||||
</div>
|
||||
{% include "partial/authorization_list.html" %}
|
||||
{% include "oidc/partial/authorization_list.html" %}
|
||||
{% endblock %}
|
|
@ -38,5 +38,5 @@
|
|||
|
||||
{{ table.search(table_form, "table.clients") }}
|
||||
</div>
|
||||
{% include "partial/client_list.html" %}
|
||||
{% include "oidc/partial/client_list.html" %}
|
||||
{% endblock %}
|
|
@ -38,5 +38,5 @@
|
|||
|
||||
{{ table.search(table_form, "table.tokens") }}
|
||||
</div>
|
||||
{% include "partial/token_list.html" %}
|
||||
{% include "oidc/partial/token_list.html" %}
|
||||
{% endblock %}
|
|
@ -307,4 +307,4 @@ def test_client_new_token(testclient, logged_admin, backend, client):
|
|||
assert client in token.audience
|
||||
|
||||
res = res.follow()
|
||||
assert res.template == "token_view.html"
|
||||
assert res.template == "oidc/token_view.html"
|
||||
|
|
Loading…
Reference in a new issue