def get_context_data(self, **kwargs): """ Dynamically set the list title for the week """ context = super(MonthEventsListView, self).get_context_data(**kwargs) start_date = self.get_start_date() now = datetime.now() if start_date.month != now.month or start_date.year != now.year: context['list_title'] = 'Events by Month: %s' % (start_date.strftime("%B %Y")) if 'all_months' not in context: context['all_months'] = OrderedDict([ ('January', '01'), ('February', '02'), ('March', '03'), ('April', '04'), ('May', '05'), ('June', '06'), ('July', '07'), ('August', '08'), ('September', '09'), ('October', '10'), ('November', '11'), ('December', '12') ]) if 'all_years' not in context: context['all_years'] = get_valid_years() return context
def get_context_data(self, **kwargs): """ Dynamically set the list title for the week """ context = super(YearEventsListView, self).get_context_data(**kwargs) start_date = self.get_start_date() if start_date.year != datetime.now().year: context['list_title'] = 'Events by Year: %s' % (start_date.strftime("%Y")) if 'all_years' not in context: context['all_years'] = get_valid_years() if 'all_months' not in context: context['all_months'] = range(1, 13) return context