Compare commits

...

3 Commits

Author SHA1 Message Date
10cfc151e1 dashboard: Add fragment with links to some misc external apps
All checks were successful
Ruff / ruff (push) Successful in 1m46s
Test / test (push) Successful in 7m5s
2024-03-15 23:38:22 -04:00
5378b74df7 dashboard: Fix typo in type annotation 2024-03-15 12:12:05 -04:00
bc52dd3369 Add permissions-based visible method to LinksCardDashboardFragment 2024-03-15 12:11:30 -04:00
3 changed files with 50 additions and 5 deletions

View File

@ -33,8 +33,15 @@ class DashboardFragment:
class LinksCardDashboardFragment(DashboardFragment):
template = "dashboard/links_card.dj.html"
links: [Link] = []
links: list[Link] = []
@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

@ -0,0 +1,42 @@
import dashboard
from dashboard import Link
from membershipworks.models import Member
from paperwork.models import Department
@dashboard.register
class ExternalAppsDashboardFragment(dashboard.LinksCardDashboardFragment):
name = "External Applications"
@property
def links(self):
links = [
Link(
"Wiki",
"https://wiki.claremontmakerspace.org",
tooltip="Uses CMS Network Computing account",
permission=None,
),
Link(
"Mailman",
"http://mailman.claremontmakerspace.org",
tooltip="Mailing list management. Uses its own authentication, for now",
permission=None,
),
]
member = Member.from_user(self.request.user)
if (
member is not None
and Department.objects.filter(shop_lead_flag__members=member).exists()
):
links.append(
Link(
"Ticketing System",
"https://tickets.claremontmakerspace.org/scp/",
tooltip="Uses CMS Network Computing account",
permission=None,
)
)
return 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")