2023-04-14 01:24:36 -04:00
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
|
|
import dashboard
|
|
|
|
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
|
|
|
|
class PaperworkDashboardFragment(dashboard.DashboardFragment):
|
|
|
|
name = "Paperwork"
|
|
|
|
template = "dashboard/links_card.dj.html"
|
|
|
|
|
|
|
|
@property
|
|
|
|
def context(self) -> Any:
|
|
|
|
links = {}
|
|
|
|
|
2023-04-25 23:23:27 -04:00
|
|
|
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.filter_by_shop_lead(member).exists()
|
|
|
|
):
|
2023-04-14 01:24:36 -04:00
|
|
|
links["Department Certifications"] = reverse(
|
|
|
|
"paperwork:department_certifications"
|
|
|
|
)
|
|
|
|
|
|
|
|
return {"links": links}
|
|
|
|
|
|
|
|
@property
|
|
|
|
def visible(self) -> bool:
|
|
|
|
return self.request.user.is_authenticated
|