Example #1
0
def test_make_ppoc():
    portfolio = PortfolioFactory.create()
    original_owner = portfolio.owner
    new_owner = UserFactory.create()

    new_owner_role = PortfolioRoles.add(user=new_owner,
                                        portfolio_id=portfolio.id)

    PortfolioRoles.make_ppoc(portfolio_role=new_owner_role)

    assert portfolio.owner is new_owner
    assert Permissions.EDIT_PORTFOLIO_POC in new_owner_role.permissions
    assert (Permissions.EDIT_PORTFOLIO_POC
            not in PortfolioRoles.get(portfolio_id=portfolio.id,
                                      user_id=original_owner.id).permissions)
Example #2
0
def update_ppoc(portfolio_id):
    role_id = http_request.form.get("role_id")

    portfolio = Portfolios.get(g.current_user, portfolio_id)
    new_ppoc_role = PortfolioRoles.get_by_id(role_id)

    PortfolioRoles.make_ppoc(portfolio_role=new_ppoc_role)

    flash("primary_point_of_contact_changed",
          ppoc_name=new_ppoc_role.full_name)

    return redirect(
        url_for(
            "portfolios.admin",
            portfolio_id=portfolio.id,
            fragment="primary-point-of-contact",
            _anchor="primary-point-of-contact",
        ))