diff --git a/src/registrar/forms/portfolio.py b/src/registrar/forms/portfolio.py index 4d99ebd80..43a391ae0 100644 --- a/src/registrar/forms/portfolio.py +++ b/src/registrar/forms/portfolio.py @@ -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): diff --git a/src/registrar/tests/test_views_portfolio.py b/src/registrar/tests/test_views_portfolio.py index 8b92fb8fe..81be0d3ad 100644 --- a/src/registrar/tests/test_views_portfolio.py +++ b/src/registrar/tests/test_views_portfolio.py @@ -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 diff --git a/src/registrar/views/portfolios.py b/src/registrar/views/portfolios.py index 61f770849..6233b9e89 100644 --- a/src/registrar/views/portfolios.py +++ b/src/registrar/views/portfolios.py @@ -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), }, )