Add in check for removing the PPoC

This commit is contained in:
George Drummond 2019-05-03 13:51:53 -04:00
parent f003baad7c
commit 360dab0a32
No known key found for this signature in database
GPG Key ID: 296DD6077123BF17
2 changed files with 7 additions and 2 deletions

View File

@ -177,6 +177,12 @@ def remove_member(portfolio_id, user_id):
g.current_user, "you cant remove yourself from the portfolio" g.current_user, "you cant remove yourself from the portfolio"
) )
portfolio = Portfolios.get(user=g.current_user, portfolio_id=portfolio_id)
if user_id == str(portfolio.owner.id):
raise UnauthorizedError(
g.current_user, "you can't delete the portfolios PPoC from the portfolio"
)
portfolio_role = PortfolioRoles.get(portfolio_id=portfolio_id, user_id=user_id) portfolio_role = PortfolioRoles.get(portfolio_id=portfolio_id, user_id=user_id)
# TODO: should this cascade and disable any application and environment # TODO: should this cascade and disable any application and environment
# roles they might have? # roles they might have?

View File

@ -358,6 +358,7 @@ def test_remove_portfolio_member_self(client, user_session):
== PortfolioRoleStatus.ACTIVE == PortfolioRoleStatus.ACTIVE
) )
def test_remove_portfolio_member_ppoc(client, user_session): def test_remove_portfolio_member_ppoc(client, user_session):
portfolio = PortfolioFactory.create() portfolio = PortfolioFactory.create()
@ -384,5 +385,3 @@ def test_remove_portfolio_member_ppoc(client, user_session):
PortfolioRoles.get(portfolio_id=portfolio.id, user_id=portfolio.owner.id).status PortfolioRoles.get(portfolio_id=portfolio.id, user_id=portfolio.owner.id).status
== PortfolioRoleStatus.ACTIVE == PortfolioRoleStatus.ACTIVE
) )