cmsmanage/paperwork/dashboard.py

39 lines
1014 B
Python
Raw Normal View History

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 (
2024-01-29 21:48:55 -05:00
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