This commit is contained in:
zandercymatics 2025-03-26 13:11:04 -06:00
parent 3bf3c5a8a6
commit 7a42b913ed
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 11 additions and 7 deletions

View file

@ -422,11 +422,15 @@ class PortfolioMemberForm(BasePortfolioMemberForm):
if role and self.instance.user.is_only_admin_of_portfolio(self.instance.portfolio):
# This is how you associate a validation error to a particular field.
# The alternative is to do this in clean_role, but execution order matters.
raise forms.ValidationError({"role": forms.ValidationError(
"You can't change your member access because you're "
"the only admin for this organization. "
"To change your access, you'll need to add another admin."
)})
raise forms.ValidationError(
{
"role": forms.ValidationError(
"You can't change your member access because you're "
"the only admin for this organization. "
"To change your access, you'll need to add another admin."
)
}
)
class PortfolioInvitedMemberForm(BasePortfolioMemberForm):

View file

@ -2159,7 +2159,7 @@ class TestPortfolioMemberDeleteView(WebTest):
# WSGIRequest protocol is basically the HTTPRequest but in Django form (ie POST '/member/1/delete')
self.assertIsInstance(args[0], WSGIRequest)
# Check that the error message matches the expected error message
self.assertEqual(args[1], expected_error_message)
self.assertIn(expected_error_message, args[1])
# Location is used for a 3xx HTTP status code to indicate that the URL was redirected
# and then confirm that we're still on the Manage Members page

View file

@ -267,7 +267,7 @@ class PortfolioMemberEditView(DetailView, View):
"form": form,
"member": user,
"portfolio_permission": portfolio_permission,
"is_only_admin": request.user.is_only_admin_of_portfolio(portfolio_permission.portfolio)
"is_only_admin": request.user.is_only_admin_of_portfolio(portfolio_permission.portfolio),
},
)