def portfolio_applications(portfolio_id): user_env_roles = EnvironmentRoles.for_user(g.current_user.id, portfolio_id) environment_access = { env_role.environment_id: env_role.role for env_role in user_env_roles } return render_template( "applications/index.html", environment_access=environment_access )
def test_for_user(application_role): portfolio = application_role.application.portfolio user = application_role.user # create roles for 2 environments associated with application_role fixture env_role_1 = EnvironmentRoleFactory.create( application_role=application_role) env_role_2 = EnvironmentRoleFactory.create( application_role=application_role) # create role for environment in a different app in same portfolio application = ApplicationFactory.create(portfolio=portfolio) env_role_3 = EnvironmentRoleFactory.create( application_role=ApplicationRoleFactory.create(application=application, user=user)) # create role for environment for random user in app2 rando_app_role = ApplicationRoleFactory.create(application=application) rando_env_role = EnvironmentRoleFactory.create( application_role=rando_app_role) env_roles = EnvironmentRoles.for_user(user.id, portfolio.id) assert len(env_roles) == 3 assert env_roles == [env_role_1, env_role_2, env_role_3] assert not rando_env_role in env_roles