from typing import Any from datetime import datetime 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-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")