Properly set deleted data for UpdateMemberForm and display suspended env access text
Styling for env name and role in update app member perms form
This commit is contained in:
parent
d40c11a8f6
commit
f928b776a6
@ -126,3 +126,11 @@ class EnvironmentRoles(object):
|
|||||||
.one_or_none()
|
.one_or_none()
|
||||||
)
|
)
|
||||||
return existing_env_role
|
return existing_env_role
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_all_for_application_member(cls, application_role_id):
|
||||||
|
return (
|
||||||
|
db.session.query(EnvironmentRole)
|
||||||
|
.filter(EnvironmentRole.application_role_id == application_role_id)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
@ -77,12 +77,16 @@ def filter_env_roles_form_data(member, environments):
|
|||||||
"environment_id": str(env.id),
|
"environment_id": str(env.id),
|
||||||
"environment_name": env.name,
|
"environment_name": env.name,
|
||||||
"role": NO_ACCESS,
|
"role": NO_ACCESS,
|
||||||
"deleted": env.deleted,
|
"deleted": False,
|
||||||
}
|
}
|
||||||
env_roles_set = set(env.roles).intersection(set(member.environment_roles))
|
env_roles_set = set(env.roles).intersection(
|
||||||
|
set(EnvironmentRoles.get_all_for_application_member(member.id))
|
||||||
|
)
|
||||||
|
|
||||||
if len(env_roles_set) == 1:
|
if len(env_roles_set) == 1:
|
||||||
(env_role,) = env_roles_set
|
(env_role,) = env_roles_set
|
||||||
env_data["role"] = env_role.role
|
env_data["role"] = env_role.role
|
||||||
|
env_data["deleted"] = env_role.deleted
|
||||||
|
|
||||||
env_roles_form_data.append(env_data)
|
env_roles_form_data.append(env_data)
|
||||||
|
|
||||||
|
@ -92,15 +92,21 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
||||||
.usa-input {
|
.usa-input {
|
||||||
margin: $gap 0 $gap 0;
|
margin: $gap * 2;
|
||||||
|
|
||||||
.usa-input__title-inline {
|
&__title-inline {
|
||||||
margin-top: $gap;
|
font-weight: $font-bold;
|
||||||
margin-left: $gap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-row {
|
&__help {
|
||||||
margin: 0;
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.env-role__no-access {
|
||||||
|
.usa-input__title-inline,
|
||||||
|
.usa-input__help {
|
||||||
|
color: $color-gray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,45 +3,30 @@
|
|||||||
{% from "components/phone_input.html" import PhoneInput %}
|
{% from "components/phone_input.html" import PhoneInput %}
|
||||||
|
|
||||||
{% macro EnvRoleInput(field, member_role_id=None) %}
|
{% macro EnvRoleInput(field, member_role_id=None) %}
|
||||||
|
{% set role = field.role.data if not field.deleted.data else "Access Suspended" %}
|
||||||
|
<div class="form-row usa-input">
|
||||||
|
<div class="form-col form-col--two-thirds">
|
||||||
|
<div class="{% if field.deleted.data or field.role.data == 'No Access' %}env-role__no-access{% endif %}">
|
||||||
|
<div v-bind:class='["usa-input__title-inline", {"environment-name--gray": value === "None" }]'>
|
||||||
|
{{ field.environment_name.data }}
|
||||||
|
</div>
|
||||||
|
<p class="usa-input__help">
|
||||||
|
{{ role }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-col form-col--third">
|
||||||
{% if field.role.data == "No Access" and not field.deleted.data -%}
|
{% if field.role.data == "No Access" and not field.deleted.data -%}
|
||||||
<optionsinput inline-template
|
<optionsinput inline-template
|
||||||
v-bind:initial-value="'{{ field.role.data | string }}'"
|
v-bind:initial-value="'{{ field.role.data | string }}'"
|
||||||
v-bind:name="'{{ field.name | string }}{% if member_role_id %}-{{ member_role_id }}{% endif %}'"
|
v-bind:name="'{{ field.name | string }}{% if member_role_id %}-{{ member_role_id }}{% endif %}'"
|
||||||
v-bind:optional="true"
|
v-bind:optional="true"
|
||||||
v-bind:watch="true">
|
v-bind:watch="true">
|
||||||
<div class="usa-input">
|
|
||||||
<fieldset data-ally-disabled="true" v-on:change="onInput" class="usa-input__choices">
|
<fieldset data-ally-disabled="true" v-on:change="onInput" class="usa-input__choices">
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-col form-col--two-thirds">
|
|
||||||
<legend>
|
|
||||||
<div v-bind:class='["usa-input__title-inline", {"environment-name--gray": value === "None" }]'>
|
|
||||||
{{ field.environment_name.data }}
|
|
||||||
</div>
|
|
||||||
<p class="usa-input__help">
|
|
||||||
{{ field.role.data }}
|
|
||||||
</p>
|
|
||||||
</legend>
|
|
||||||
</div>
|
|
||||||
<div class="form-col form-col--third">
|
|
||||||
{{ field.role(**{"v-model": "value", "id": "{}-{}".format(field.role.name, member_role_id)}) }}
|
{{ field.role(**{"v-model": "value", "id": "{}-{}".format(field.role.name, member_role_id)}) }}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
|
||||||
</optionsinput>
|
</optionsinput>
|
||||||
{% elif field.role.data != "No Access" and not field.deleted.data -%}
|
{% elif field.role.data != "No Access" and not field.deleted.data -%}
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-col form-col--two-thirds">
|
|
||||||
<legend>
|
|
||||||
<div v-bind:class='["usa-input__title-inline", {"environment-name--gray": value === "None" }]'>
|
|
||||||
{{ field.environment_name.data }}
|
|
||||||
</div>
|
|
||||||
<p class="usa-input__help">
|
|
||||||
{{ field.role.data }}
|
|
||||||
</p>
|
|
||||||
</legend>
|
|
||||||
</div>
|
|
||||||
<div class="form-col form-col--third">
|
|
||||||
<checkboxinput
|
<checkboxinput
|
||||||
name="'{{ field.deleted.name | string }}-{% if member_role_id %}-{{ member_role_id }}{% endif %}'"
|
name="'{{ field.deleted.name | string }}-{% if member_role_id %}-{{ member_role_id }}{% endif %}'"
|
||||||
inline-template
|
inline-template
|
||||||
@ -49,9 +34,6 @@
|
|||||||
v-bind:initial-checked='{{ field.deleted.data|string|lower }}'
|
v-bind:initial-checked='{{ field.deleted.data|string|lower }}'
|
||||||
v-bind:optional="true"
|
v-bind:optional="true"
|
||||||
>
|
>
|
||||||
<div>
|
|
||||||
<div class='usa-input' v-bind:class="[{ 'checked': isChecked }]">
|
|
||||||
|
|
||||||
<fieldset data-ally-disabled="true" v-on:change="onInput" class="usa-input__choices {% if inline %}usa-input__choices--inline{% endif %}">
|
<fieldset data-ally-disabled="true" v-on:change="onInput" class="usa-input__choices {% if inline %}usa-input__choices--inline{% endif %}">
|
||||||
<legend>
|
<legend>
|
||||||
{% set id = "{}-{}".format(field.deleted.name, member_role_id) %}
|
{% set id = "{}-{}".format(field.deleted.name, member_role_id) %}
|
||||||
@ -59,13 +41,15 @@
|
|||||||
{{ field.deleted.label(for=id) | safe }}
|
{{ field.deleted.label(for=id) | safe }}
|
||||||
</legend>
|
</legend>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</checkboxinput>
|
</checkboxinput>
|
||||||
</div>
|
{% elif field.deleted.data -%}
|
||||||
</div>
|
<p class="usa-input__help">
|
||||||
|
Suspended access cannot be modified.
|
||||||
|
</p>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{{ field.environment_id() }}
|
{{ field.environment_id() }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro PermsFields(form, new=False, member_role_id=None) %}
|
{% macro PermsFields(form, new=False, member_role_id=None) %}
|
||||||
|
@ -93,12 +93,21 @@ def test_disable_completed(application_role, environment):
|
|||||||
assert environment_role.status == EnvironmentRole.Status.DISABLED
|
assert environment_role.status == EnvironmentRole.Status.DISABLED
|
||||||
|
|
||||||
|
|
||||||
def test_get_for_update():
|
def test_get_for_update(application_role, environment):
|
||||||
app_role = ApplicationRoleFactory.create()
|
EnvironmentRoleFactory.create(
|
||||||
env = EnvironmentFactory.create(application=app_role.application)
|
application_role=application_role, environment=environment, deleted=True
|
||||||
EnvironmentRoleFactory.create(application_role=app_role, environment=env, deleted=True)
|
)
|
||||||
role = EnvironmentRoles.get_for_update(app_role.id, env.id)
|
role = EnvironmentRoles.get_for_update(application_role.id, environment.id)
|
||||||
assert role
|
assert role
|
||||||
assert role.application_role == app_role
|
assert role.application_role == application_role
|
||||||
assert role.environment == env
|
assert role.environment == environment
|
||||||
assert role.deleted
|
assert role.deleted
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_all_for_application_member(application_role, environment):
|
||||||
|
EnvironmentRoleFactory.create(
|
||||||
|
application_role=application_role, environment=environment, deleted=True
|
||||||
|
)
|
||||||
|
|
||||||
|
roles = EnvironmentRoles.get_all_for_application_member(application_role.id)
|
||||||
|
assert len(roles) == 1
|
||||||
|
@ -61,9 +61,7 @@ def test_update_env_role_no_change():
|
|||||||
|
|
||||||
def test_update_env_role_deleted_role():
|
def test_update_env_role_deleted_role():
|
||||||
env_role = EnvironmentRoleFactory.create(role=CSPRole.BASIC_ACCESS.value)
|
env_role = EnvironmentRoleFactory.create(role=CSPRole.BASIC_ACCESS.value)
|
||||||
Environments.update_env_role(
|
Environments.update_env_role(env_role.environment, env_role.application_role, None)
|
||||||
env_role.environment, env_role.application_role, None
|
|
||||||
)
|
|
||||||
assert not Environments.update_env_role(
|
assert not Environments.update_env_role(
|
||||||
env_role.environment, env_role.application_role, CSPRole.TECHNICAL_READ.value
|
env_role.environment, env_role.application_role, CSPRole.TECHNICAL_READ.value
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user