cmsmanage/paperwork/dashboard.py

73 lines
2.1 KiB
Python
Raw Permalink Normal View History

from django.urls import reverse
import dashboard
from dashboard import Link
from membershipworks.models import Member
from .models import Department
@dashboard.register
class PaperworkDashboardFragment(dashboard.LinksCardDashboardFragment):
name = "Paperwork"
@property
def links(self) -> list[Link]:
links = [
Link(
"Waivers",
reverse("paperwork:waivers-report"),
permission="paperwork.view_waiver",
),
Link(
"Instructors and Vendors",
reverse("paperwork:instructors-and-vendor-report"),
permission="paperwork.view_instructororvendor",
),
Link(
"Access Verification",
reverse("paperwork:access-verification-report"),
permission="paperwork.view_certification",
),
Link(
"Certifiers",
reverse("paperwork:certifiers-report"),
permission="paperwork.view_certification",
),
Link(
"Certification Count",
reverse("paperwork:certification-count-report"),
permission="paperwork.view_certification",
),
]
member = Member.from_user(self.request.user)
if member is not None:
links.append(
dashboard.Link(
"Member Certifications",
reverse(
"paperwork:member_certifications", kwargs={"uid": member.uid}
),
permission=None,
)
)
if self.request.user.is_superuser or (
2024-01-29 21:48:55 -05:00
member is not None
and Department.objects.filter_by_shop_lead(member).exists()
):
links.append(
Link(
"Department Certifications",
reverse("paperwork:department_certifications"),
permission=None,
)
)
return links
@property
def visible(self) -> bool:
return self.request.user.is_authenticated