cmsmanage/membershipworks/dashboard.py

50 lines
1.5 KiB
Python
Raw Normal View History

from django.urls import reverse
import dashboard
from dashboard import Link
from membershipworks.models import EventExt, Member
@dashboard.register
class MembershipworksDashboardFragment(dashboard.LinksCardDashboardFragment):
name = "MembershipWorks"
@property
def links(self):
links = [
Link(
"Upcoming Events",
reverse("membershipworks:upcoming-events"),
permission="membershipworks.view_event",
tooltip="Generator for Wordpress posts",
),
Link(
"Event Report",
reverse("membershipworks:event-index-report"),
permission="membershipworks.view_event",
),
Link(
"Event Attendees",
reverse("membershipworks:event-attendees"),
permission="membershipworks.view_event",
),
Link(
"Missing Paperwork",
reverse("membershipworks:missing-paperwork-report"),
permission="membershipworks.view_member",
),
]
member = Member.from_user(self.request.user)
if (
member is not None
and EventExt.objects.filter(instructor__member=member).exists()
):
links.append(
Link(
"My Events", reverse("membershipworks:user-events"), permission=None
)
)
return links