from typing import Any from django.urls import reverse import dashboard from membershipworks.models import Member from .models import Department @dashboard.register class PaperworkDashboardFragment(dashboard.DashboardFragment): name = "Paperwork" template = "dashboard/links_card.dj.html" @property def context(self) -> Any: links = {} member = Member.from_user(self.request.user) if member is not None: links["Member Certifications"] = reverse( "paperwork:member_certifications", kwargs={"uid": member.uid} ) if self.request.user.is_superuser or ( member is not None and Department.objects.filter_by_shop_lead(member).exists() ): links["Department Certifications"] = reverse( "paperwork:department_certifications" ) return {"links": links} @property def visible(self) -> bool: return self.request.user.is_authenticated