Update app member status labels to accurately reflect member's current status

This commit is contained in:
leigh-mil
2019-11-18 16:43:53 -05:00
parent 3f146c7da8
commit 9f90f5abbd
9 changed files with 76 additions and 20 deletions

View File

@@ -102,6 +102,14 @@ class ApplicationRole(
"portfolio": self.application.portfolio.name,
}
@property
def is_pending(self):
return self.status == Status.PENDING
@property
def is_active(self):
return self.status == Status.ACTIVE
Index(
"application_role_user_application",

View File

@@ -70,6 +70,10 @@ class EnvironmentRole(
def disabled(self):
return self.status == EnvironmentRole.Status.DISABLED
@property
def is_pending(self):
return self.status == EnvironmentRole.Status.PENDING
@property
def event_details(self):
return {

View File

@@ -153,6 +153,7 @@ def view_new_application_step_3(application_id):
application=application,
members=members,
new_member_form=new_member_form,
label_info=LABEL_INFO,
)

View File

@@ -21,6 +21,19 @@ from atst.utils.localization import translate
from atst.jobs import send_mail
LABEL_INFO = {
"pending": {"icon": "envelope", "text": "invite pending", "type": "success",},
"expired": {"icon": "envelope", "text": "invite expired", "type": "error",},
"env_changes_pending": {
"icon": "exchange",
"text": "changes pending",
"type": "default",
},
"active": None,
"disabled": None,
}
def get_environments_obj_for_app(application):
return sorted(
[
@@ -98,6 +111,20 @@ def filter_env_roles_form_data(member, environments):
return env_roles_form_data
def get_app_role_status(app_role):
status = app_role.status.value
if app_role.is_pending and app_role.latest_invitation.is_expired:
status = "expired"
if app_role.is_active and any(
env_role.is_pending for env_role in app_role.environment_roles
):
status = "env_changes_pending"
return status
def get_members_data(application):
members_data = []
for member in application.members:
@@ -122,7 +149,7 @@ def get_members_data(application):
"user_name": member.user_name,
"permission_sets": permission_sets,
"environment_roles": environment_roles,
"role_status": member.status.value,
"role_status": get_app_role_status(member),
"form": form,
"update_invite_form": update_invite_form,
}
@@ -164,6 +191,7 @@ def render_settings_page(application, **kwargs):
audit_events=audit_events,
new_member_form=new_member_form,
members=members,
label_info=LABEL_INFO,
**kwargs,
)