cmsmanage/membershipworks/dashboard.py

30 lines
763 B
Python

from datetime import datetime
from typing import Any
from django.urls import reverse
import dashboard
@dashboard.register
class MembershipworksDashboardFragment(dashboard.DashboardFragment):
name = "MembershipWorks"
template = "dashboard/links_card.dj.html"
@property
def context(self) -> Any:
links = {}
if self.request.user.has_perm("membershipworks.view_event"):
now = datetime.now()
links["Event Report"] = reverse(
"membershipworks:event-month-report",
kwargs={"year": now.year, "month": now.month},
)
return {"links": links}
@property
def visible(self) -> bool:
return self.request.user.has_perm("doorcontrol.view_hidevent")