Use application_role_id on environment_roles.
In the future, an `application_invitation1 will not refer to a `user` until someone accepts the invitation; they'll only reference an `application_role`. When a user is invited to an application, the inviter can specify the environments the invitee should have access to. For this to be possible, an `environment_role` should reference an `application_role`, because no `user` entity will be known at that time. In addition to updating all the models and domain methods necessary for this change, this commit deletes unused code and tests that were dependent on `environment_roles` having a `user_id` foreign key.
This commit is contained in:
@@ -17,7 +17,7 @@ applications_bp.context_processor(portfolio_context_processor)
|
||||
|
||||
|
||||
def wrap_environment_role_lookup(user, environment_id=None, **kwargs):
|
||||
env_role = EnvironmentRoles.get(user.id, environment_id)
|
||||
env_role = EnvironmentRoles.get_by_user_and_environment(user.id, environment_id)
|
||||
if not env_role:
|
||||
raise UnauthorizedError(user, "access environment {}".format(environment_id))
|
||||
|
||||
@@ -27,7 +27,9 @@ def wrap_environment_role_lookup(user, environment_id=None, **kwargs):
|
||||
@applications_bp.route("/environments/<environment_id>/access")
|
||||
@user_can(None, override=wrap_environment_role_lookup, message="access environment")
|
||||
def access_environment(environment_id):
|
||||
env_role = EnvironmentRoles.get(g.current_user.id, environment_id)
|
||||
env_role = EnvironmentRoles.get_by_user_and_environment(
|
||||
g.current_user.id, environment_id
|
||||
)
|
||||
token = app.csp.cloud.get_access_token(env_role)
|
||||
|
||||
return redirect(url_for("atst.csp_environment_access", token=token))
|
||||
|
||||
@@ -38,9 +38,7 @@ def get_team_form(application):
|
||||
member, PermissionSets.DELETE_APPLICATION_ENVIRONMENTS
|
||||
),
|
||||
}
|
||||
roles = EnvironmentRoles.get_for_application_and_user(
|
||||
member.user.id, application.id
|
||||
)
|
||||
roles = EnvironmentRoles.get_for_application_member(member.id)
|
||||
environment_roles = [
|
||||
{
|
||||
"environment_id": str(role.environment.id),
|
||||
@@ -110,7 +108,7 @@ def update_team(application_id):
|
||||
environment_role_form.environment_id.data
|
||||
)
|
||||
Environments.update_env_role(
|
||||
environment, app_role.user, environment_role_form.data.get("role")
|
||||
environment, app_role, environment_role_form.data.get("role")
|
||||
)
|
||||
|
||||
flash("updated_application_team_settings", application_name=application.name)
|
||||
|
||||
Reference in New Issue
Block a user