Move display status logic to be a property of an ApplicationRole

This commit is contained in:
leigh-mil
2019-11-19 10:43:11 -05:00
parent 9f90f5abbd
commit 58a0b2dd9d
4 changed files with 48 additions and 15 deletions

View File

@@ -110,6 +110,29 @@ class ApplicationRole(
def is_active(self):
return self.status == Status.ACTIVE
@property
def display_status(self):
if (
self.is_pending
and self.latest_invitation
and self.latest_invitation.is_pending
):
return "invite_pending"
elif (
self.is_pending
and self.latest_invitation
and self.latest_invitation.is_expired
):
return "invite_expired"
elif self.is_active and any(
env_role.is_pending for env_role in self.environment_roles
):
return "changes_pending"
return None
Index(
"application_role_user_application",