Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render(self, context):
if self.calendar_slug == 'all':
events = EventTime.upcoming_objects.all().order_by('start')
else:
events = EventTime.upcoming_objects.filter(event__calendar__slug=self.calendar_slug).order_by('start')
if self.excluded_cals:
for cal_slug in self.excluded_cals:
events = events.exclude(event__calendar__slug=cal_slug)
logging.debug('Fetching %s events from calendar %s excluding %s.' % (self.limit, self.calendar_slug, self.excluded_cals))
if self.limit == 1:
try:
context[self.varname] = events[0]
except:
context[self.varname] = None
else:
try:
context[self.varname] = events[:self.limit]
def render(self, context):
if self.calendar_slug == 'all':
events = EventTime.upcoming_objects.all().order_by('start')
else:
events = EventTime.upcoming_objects.filter(event__calendar__slug=self.calendar_slug).order_by('start')
if self.excluded_cals:
for cal_slug in self.excluded_cals:
events = events.exclude(event__calendar__slug=cal_slug)
logging.debug('Fetching %s events from calendar %s excluding %s.' % (self.limit, self.calendar_slug, self.excluded_cals))
if self.limit == 1:
try:
context[self.varname] = events[0]
except:
context[self.varname] = None
else:
try:
context[self.varname] = events[:self.limit]
except:
context[self.varname] = None
def get_queryset(self):
try:
cal_slug = self.kwargs['cal_slug']
self.calendar = get_object_or_404(Calendar, slug=cal_slug)
except:
self.calendar = None
return EventTime.upcoming_objects.all()
def get_queryset(self):
try:
if self.kwargs['cal_slug']:
return EventTime.upcoming_objects.filter(event__calendar__slug=self.kwargs['cal_slug'])
except:
pass
try:
if self.kwargs['slug']:
return EventTime.upcoming_objects.filter(event__slug=self.kwargs['slug'])
except:
logging.debug('Returning all upcoming events...')
return EventTime.upcoming_objects.all()