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 = [] 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 ( 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