From 5b87d9ff0361a08b741e1a12e8b753f1885c405e Mon Sep 17 00:00:00 2001 From: Finn Stutzenstein Date: Wed, 21 Oct 2026 19:24:37 +0000 Subject: [PATCH] Fix HTTP 500 on the create pages with ?return=detail UserCreate and AliasCreate used BackToUsersMixin and BackToAliasesMixin, which access self.user or self.alias for ?return=detail. Neither exists on the create pages, so the request failed with an AttributeError. Both views now define their own back link with the target they already used without the parameter: the user list and the user's detail page. Co-Authored-By: Claude Opus 5.5 --- max/routes/alias/create.py | 10 +++++----- max/routes/user/create.py | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/max/routes/alias/create.py b/max/routes/alias/create.py index 0c298c5..436268f 100644 --- a/max/routes/alias/create.py +++ b/max/routes/alias/create.py @@ -1,22 +1,22 @@ -from flask import flash +from flask import flash, url_for from max.db import EmailAlreadyExists, create_alias, get_domains from max.permissions import AllowAdminOrSelf from max.translations import t -from ..base_alias_views import BackToAliasesMixin from ..base_user_views import FetchUserTemplateGetView from ..check_email_mixin import CheckEmailMixin -class AliasCreate( - AllowAdminOrSelf, CheckEmailMixin, BackToAliasesMixin, FetchUserTemplateGetView -): +class AliasCreate(AllowAdminOrSelf, CheckEmailMixin, FetchUserTemplateGetView): template_name = "alias/create.html" def get_webpagetitle(self): return f"Create new alias for {self.user.email}" + def get_back_text_and_url(self): + return self.user.email, url_for("user-detail", user_id=self.user.id) + def post(self): error = False email = self.request.form.get("email") diff --git a/max/routes/user/create.py b/max/routes/user/create.py index cc1c580..e1133fb 100644 --- a/max/routes/user/create.py +++ b/max/routes/user/create.py @@ -1,4 +1,4 @@ -from flask import flash +from flask import flash, url_for from max.auth import hash_password from max.db import EmailAlreadyExists, create_user, get_domains @@ -6,11 +6,10 @@ from max.permissions import AllowAdmin from max.translations import t from max.views import BaseTemplateGetView -from ..base_user_views import BackToUsersMixin from ..check_email_mixin import CheckEmailMixin -class UserCreate(AllowAdmin, CheckEmailMixin, BackToUsersMixin, BaseTemplateGetView): +class UserCreate(AllowAdmin, CheckEmailMixin, BaseTemplateGetView): template_name = "user/create.html" def post(self): @@ -134,3 +133,6 @@ class UserCreate(AllowAdmin, CheckEmailMixin, BackToUsersMixin, BaseTemplateGetV def get_webpagetitle(self): return t("Create new user") + + def get_back_text_and_url(self): + return t("User list"), url_for("user-list")