[templates] Add pill buttons to calendar
This commit is contained in:
@ -1305,6 +1305,8 @@ class ScrobbleCalendarView(LoginRequiredMixin, TemplateView):
|
||||
"Mood": "🥰",
|
||||
}
|
||||
|
||||
DEFAULT_EXCLUDE = ["Task"]
|
||||
|
||||
MONTH_COLORS = [
|
||||
"#db7a7a", # Jan
|
||||
"#db847a", # Feb
|
||||
@ -1345,12 +1347,18 @@ class ScrobbleCalendarView(LoginRequiredMixin, TemplateView):
|
||||
prev_month = month_start - timedelta(days=1)
|
||||
next_month = month_end + timedelta(days=1)
|
||||
|
||||
media_type_filter = self.request.GET.get("media_type")
|
||||
if media_type_filter and media_type_filter in self.CALENDAR_MEDIA_TYPES:
|
||||
active_types = [media_type_filter]
|
||||
else:
|
||||
active_types = [t for t in self.CALENDAR_MEDIA_TYPES if t not in self.DEFAULT_EXCLUDE]
|
||||
|
||||
scrobbles = (
|
||||
Scrobble.objects.filter(
|
||||
user=self.request.user,
|
||||
timestamp__date__gte=month_start,
|
||||
timestamp__date__lte=month_end,
|
||||
media_type__in=self.CALENDAR_MEDIA_TYPES,
|
||||
media_type__in=active_types,
|
||||
)
|
||||
.select_related("task", "birding_location", "food", "trail", "video_game", "book", "mood")
|
||||
.order_by("timestamp")
|
||||
@ -1400,6 +1408,8 @@ class ScrobbleCalendarView(LoginRequiredMixin, TemplateView):
|
||||
"current_month": today.isoformat()[:7],
|
||||
"day_names": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
"month_color": month_color,
|
||||
"active_filter": media_type_filter or "",
|
||||
"media_types": [{"name": mt, "emoji": self.MEDIA_EMOJI.get(mt, "📌")} for mt in self.CALENDAR_MEDIA_TYPES],
|
||||
}
|
||||
)
|
||||
return ctx
|
||||
|
||||
Reference in New Issue
Block a user