def show_calendar(context, req=None, mini=False, inherit_context=False): req = req or context.get('request', None) if not (req and hasattr(req, 'path') and hasattr(req, 'META')): raise TemplateSyntaxError(r"{% show_calendar %} should be called with HttpRequest instance as first argument or it should be available as `request` variable in template context") now = get_now() net, category, tag = get_net_category_tag(req) year = now.year month = now.month + net year, month, error = clean_year_month(year, month, None) prefetch = {'loc': True, 'cncl': True} if mini: prefetch['loc'] = False # locations aren't displayed on mini calendar all_month_events = list(Event.objects.all_month_events( year, month, category, tag, **prefetch )) all_month_events.sort(key=lambda x: x.l_start_date.hour) qs = req.META['QUERY_STRING'] if qs: # get any querystrings that are not next/prev qs = get_qs(qs) if not inherit_context: context = {} return month_display( year, month, all_month_events, start_day, net, qs, mini=mini, request=req, context=context, )
def get_context_data(self, **kwargs): context = super(GenericEventView, self).get_context_data(**kwargs) self.net, self.category, self.tag = c.get_net_category_tag( self.request) if self.category is not None: context['cal_category'] = self.category if self.tag is not None: context['cal_tag'] = self.tag return context
def get_context_data(self, **kwargs): context = super(GenericEventView, self).get_context_data(**kwargs) self.net, self.category, self.tag = c.get_net_category_tag( self.request ) if self.category is not None: context['cal_category'] = self.category if self.tag is not None: context['cal_tag'] = self.tag return context
def show_calendar(req, mini=False): now = get_now() net, category, tag = get_net_category_tag(req) year = now.year month = now.month + net year, month, error = clean_year_month(year, month, None) prefetch = {'loc': True, 'cncl': True} if mini: prefetch['loc'] = False # locations aren't displayed on mini calendar all_month_events = list(Event.objects.all_month_events( year, month, category, tag, **prefetch )) all_month_events.sort(key=lambda x: x.l_start_date.hour) qs = req.META['QUERY_STRING'] if qs: # get any querystrings that are not next/prev qs = get_qs(qs) return month_display( year, month, all_month_events, start_day, net, qs, mini=mini )