2023-04-14 01:24:36 -04:00
|
|
|
from django.urls import reverse
|
|
|
|
|
|
|
|
import dashboard
|
2024-02-06 00:41:01 -05:00
|
|
|
from dashboard import Link
|
2023-04-14 01:24:36 -04:00
|
|
|
from membershipworks.models import Member
|
2024-01-17 21:17:24 -05:00
|
|
|
|
2023-04-14 01:24:36 -04:00
|
|
|
from .models import Department
|
|
|
|
|
|
|
|
|
|
|
|
@dashboard.register
|
2024-02-06 00:41:01 -05:00
|
|
|
class PaperworkDashboardFragment(dashboard.LinksCardDashboardFragment):
|
2023-04-14 01:24:36 -04:00
|
|
|
name = "Paperwork"
|
|
|
|
|
|
|
|
@property
|
2024-02-06 00:41:01 -05:00
|
|
|
def links(self) -> list[Link]:
|
2024-02-07 00:25:39 -05:00
|
|
|
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",
|
|
|
|
),
|
2024-02-07 21:03:19 -05:00
|
|
|
Link(
|
|
|
|
"Access Verification",
|
|
|
|
reverse("paperwork:access-verification-report"),
|
|
|
|
permission="paperwork.view_certification",
|
|
|
|
),
|
2024-02-07 00:25:39 -05:00
|
|
|
]
|
2023-04-14 01:24:36 -04:00
|
|
|
|
2023-04-25 23:23:27 -04:00
|
|
|
member = Member.from_user(self.request.user)
|
|
|
|
if member is not None:
|
2024-02-06 00:41:01 -05:00
|
|
|
links.append(
|
|
|
|
dashboard.Link(
|
|
|
|
"Member Certifications",
|
|
|
|
reverse(
|
|
|
|
"paperwork:member_certifications", kwargs={"uid": member.uid}
|
|
|
|
),
|
|
|
|
permission=None,
|
|
|
|
)
|
2023-04-25 23:23:27 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
2023-04-25 23:23:27 -04:00
|
|
|
):
|
2024-02-06 00:41:01 -05:00
|
|
|
links.append(
|
|
|
|
Link(
|
|
|
|
"Department Certifications",
|
|
|
|
reverse("paperwork:department_certifications"),
|
|
|
|
permission=None,
|
|
|
|
)
|
2023-04-14 01:24:36 -04:00
|
|
|
)
|
|
|
|
|
2024-02-06 00:41:01 -05:00
|
|
|
return links
|
2023-04-14 01:24:36 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def visible(self) -> bool:
|
|
|
|
return self.request.user.is_authenticated
|