Use portfolio_role entity to display and update portfolio member info.
Previously, we were encoding the portfolio_role.user_id as part of the form data for the portfolio admin page. This was convenient because it allowed us to easily determine certain display attributes in the template. Instead, we should rely on the PortfolioRole as the source of truth for member information. This commit adds: - Portfolio.owner_role to return the PortfolioRole of the owner - explicitly passes the PortfolioRole IDs for the PPoC and current user to the template - PortfolioRole.full_name for deriving the member name
This commit is contained in:
@@ -26,14 +26,18 @@ class Portfolio(Base, mixins.TimestampsMixin, mixins.AuditableMixin):
|
||||
task_orders = relationship("TaskOrder")
|
||||
|
||||
@property
|
||||
def owner(self):
|
||||
def owner_role(self):
|
||||
def _is_portfolio_owner(portfolio_role):
|
||||
return PermissionSets.PORTFOLIO_POC in [
|
||||
perms_set.name for perms_set in portfolio_role.permission_sets
|
||||
]
|
||||
|
||||
owner = first_or_none(_is_portfolio_owner, self.roles)
|
||||
return owner.user if owner else None
|
||||
return first_or_none(_is_portfolio_owner, self.roles)
|
||||
|
||||
@property
|
||||
def owner(self):
|
||||
owner_role = self.owner_role
|
||||
return owner_role.user if owner_role else None
|
||||
|
||||
@property
|
||||
def users(self):
|
||||
|
@@ -160,6 +160,10 @@ class PortfolioRole(
|
||||
self.latest_invitation and self.latest_invitation.is_inactive
|
||||
)
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
return self.user.full_name
|
||||
|
||||
|
||||
Index(
|
||||
"portfolio_role_user_portfolio",
|
||||
|
Reference in New Issue
Block a user