Add permissions-based visible method to LinksCardDashboardFragment

This commit is contained in:
Adam Goldsmith 2024-03-08 15:37:36 -05:00
parent aef53b1828
commit bc52dd3369
2 changed files with 7 additions and 4 deletions

View File

@ -38,3 +38,10 @@ class LinksCardDashboardFragment(DashboardFragment):
@property
def context(self):
return {"links": self.links}
@property
def visible(self) -> bool:
return any(
link.permission is None or self.request.user.has_perm(link.permission)
for link in self.links
)

View File

@ -31,7 +31,3 @@ class MembershipworksDashboardFragment(dashboard.LinksCardDashboardFragment):
permission="membershipworks.view_member",
),
]
@property
def visible(self) -> bool:
return self.request.user.has_perm("doorcontrol.view_hidevent")