Add status labels to portfolio managers table.
Update PortfolioRole.display_status() to return same type of data as ApplicationRole.display_status().
This commit is contained in:
parent
a6fcd0c76f
commit
da398bf1ff
@ -12,17 +12,6 @@ from atst.utils import first_or_none
|
||||
from atst.models.mixins.auditable import record_permission_sets_updates
|
||||
|
||||
|
||||
MEMBER_STATUSES = {
|
||||
"active": "Active",
|
||||
"revoked": "Invite revoked",
|
||||
"expired": "Invite expired",
|
||||
"error": "Error on invite",
|
||||
"pending": "Pending",
|
||||
"unknown": "Unknown errors",
|
||||
"disabled": "Disabled",
|
||||
}
|
||||
|
||||
|
||||
class Status(Enum):
|
||||
ACTIVE = "active"
|
||||
DISABLED = "disabled"
|
||||
@ -90,23 +79,23 @@ class PortfolioRole(
|
||||
@property
|
||||
def display_status(self):
|
||||
if self.status == Status.ACTIVE:
|
||||
return MEMBER_STATUSES["active"]
|
||||
return "active"
|
||||
elif self.status == Status.DISABLED:
|
||||
return MEMBER_STATUSES["disabled"]
|
||||
return "disabled"
|
||||
elif self.latest_invitation:
|
||||
if self.latest_invitation.is_revoked:
|
||||
return MEMBER_STATUSES["revoked"]
|
||||
return "invite_revoked"
|
||||
elif self.latest_invitation.is_rejected_wrong_user:
|
||||
return MEMBER_STATUSES["error"]
|
||||
return "invite_error"
|
||||
elif (
|
||||
self.latest_invitation.is_rejected_expired
|
||||
or self.latest_invitation.is_expired
|
||||
):
|
||||
return MEMBER_STATUSES["expired"]
|
||||
return "invite_expired"
|
||||
else:
|
||||
return MEMBER_STATUSES["pending"]
|
||||
return "invite_pending"
|
||||
else:
|
||||
return MEMBER_STATUSES["unknown"]
|
||||
return "unknown"
|
||||
|
||||
def has_permission_set(self, perm_set_name):
|
||||
return first_or_none(
|
||||
|
@ -46,6 +46,7 @@ def filter_members_data(members_list):
|
||||
"role_id": member.id,
|
||||
"user_name": member.user_name,
|
||||
"permission_sets": filter_perm_sets_data(member),
|
||||
"status": member.display_status,
|
||||
# add in stuff here for forms
|
||||
}
|
||||
)
|
||||
|
@ -9,11 +9,15 @@
|
||||
"text": "changes pending",
|
||||
"color": "default",
|
||||
},
|
||||
"ppoc": {"text": "primary point of contact"}
|
||||
} %}
|
||||
|
||||
{% if type -%}
|
||||
{% if type in label_info.keys() -%}
|
||||
<span class='label label--{{ label_info[type]["color"] }} {{ classes }}'>
|
||||
{{ Icon(label_info[type]["icon"]) }} {{ label_info[type]["text"] }}
|
||||
{% if label_info[type]["icon"] %}
|
||||
{{ Icon(label_info[type]["icon"]) }}
|
||||
{% endif %}
|
||||
{{ label_info[type]["text"] }}
|
||||
</span>
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
@ -1,5 +1,6 @@
|
||||
{% extends "portfolios/base.html" %}
|
||||
|
||||
{% from "components/label.html" import Label %}
|
||||
{% from "components/pagination.html" import Pagination %}
|
||||
{% from 'components/save_button.html' import SaveButton %}
|
||||
{% from 'components/sticky_cta.html' import StickyCTA %}
|
||||
|
@ -21,6 +21,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{{ ppoc.user_name }}{% if ppoc.role_id == current_member_id %} (You){% endif %}</strong>
|
||||
<br>
|
||||
{{ Label(type="ppoc", classes='label--below label--purple')}}
|
||||
</td>
|
||||
<td>
|
||||
{% for perm, value in ppoc.permission_sets.items() -%}
|
||||
@ -34,6 +36,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{{ member.user_name }}{% if member.role_id == current_member_id %} (You){% endif %}</strong>
|
||||
<br>
|
||||
{{ Label(type=member.status, classes='label--below')}}
|
||||
</td>
|
||||
<td>
|
||||
{% for perm, value in member.permission_sets.items() -%}
|
||||
|
@ -151,12 +151,12 @@ def test_event_details():
|
||||
|
||||
def test_status_when_member_is_active():
|
||||
portfolio_role = PortfolioRoleFactory.create(status=PortfolioRoleStatus.ACTIVE)
|
||||
assert portfolio_role.display_status == "Active"
|
||||
assert portfolio_role.display_status == "active"
|
||||
|
||||
|
||||
def test_status_when_member_is_disabled():
|
||||
portfolio_role = PortfolioRoleFactory.create(status=PortfolioRoleStatus.DISABLED)
|
||||
assert portfolio_role.display_status == "Disabled"
|
||||
assert portfolio_role.display_status == "disabled"
|
||||
|
||||
|
||||
def test_status_when_invitation_has_been_rejected_for_expirations():
|
||||
@ -168,7 +168,7 @@ def test_status_when_invitation_has_been_rejected_for_expirations():
|
||||
PortfolioInvitationFactory.create(
|
||||
role=portfolio_role, status=InvitationStatus.REJECTED_EXPIRED
|
||||
)
|
||||
assert portfolio_role.display_status == "Invite expired"
|
||||
assert portfolio_role.display_status == "invite_expired"
|
||||
|
||||
|
||||
def test_status_when_invitation_has_been_rejected_for_wrong_user():
|
||||
@ -180,7 +180,7 @@ def test_status_when_invitation_has_been_rejected_for_wrong_user():
|
||||
PortfolioInvitationFactory.create(
|
||||
role=portfolio_role, status=InvitationStatus.REJECTED_WRONG_USER
|
||||
)
|
||||
assert portfolio_role.display_status == "Error on invite"
|
||||
assert portfolio_role.display_status == "invite_error"
|
||||
|
||||
|
||||
def test_status_when_invitation_has_been_revoked():
|
||||
@ -192,7 +192,7 @@ def test_status_when_invitation_has_been_revoked():
|
||||
PortfolioInvitationFactory.create(
|
||||
role=portfolio_role, status=InvitationStatus.REVOKED
|
||||
)
|
||||
assert portfolio_role.display_status == "Invite revoked"
|
||||
assert portfolio_role.display_status == "invite_revoked"
|
||||
|
||||
|
||||
def test_status_when_invitation_is_expired():
|
||||
@ -206,7 +206,7 @@ def test_status_when_invitation_is_expired():
|
||||
status=InvitationStatus.PENDING,
|
||||
expiration_time=datetime.datetime.now() - datetime.timedelta(seconds=1),
|
||||
)
|
||||
assert portfolio_role.display_status == "Invite expired"
|
||||
assert portfolio_role.display_status == "invite_expired"
|
||||
|
||||
|
||||
def test_can_not_resend_invitation_if_active():
|
||||
|
Loading…
x
Reference in New Issue
Block a user