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 <noreply@anthropic.com>
This commit is contained in:
finnandClaude Opus 5.5 committed 2026-10-21 19:24:37 +00:00
1 parent 91eaef7f93
commit 5b87d9ff03
2 files changed
+10 -8

No files matched your search

+5 -5
View File
@@ -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")