Пример #1
0
def tag_detail_ical(request, slug):
	tag = Event.tags.get(slug=slug)
	event_list = Event.objects.upcoming(tags__in=[tag])[:10]
	
	icalendar = export_ical(event_list)
	
	response = HttpResponse(icalendar.as_string(), mimetype="text/calendar")
	response['Content-Disposition'] = 'attachment: filename=%s.ics' % slug
	
	return response
Пример #2
0
def ical(request):
	TODAY = datetime.date.today()
	THRIDY_DAYS = datetime.timedelta(days=30)
	
	FUTURE = TODAY + THRIDY_DAYS
	PAST = TODAY - THRIDY_DAYS
	
	event_list = Event.objects.filter(start_date__lte=FUTURE, start_date__gte=PAST)
	
	icalendar = export_ical(event_list)
	
	response = HttpResponse(icalendar.as_string(), mimetype="text/calendar")
	response['Content-Disposition'] = 'attachment: filename=%s-%s.ics' % (FUTURE.isoformat(), PAST.isoformat())
	
	return response
Пример #3
0
def detail_ical(request, year, month, day, slug):
	try:
		date = datetime.date(*time.strptime(year+month+day, '%Y%b%d')[:3])
	except ValueError:
		raise Http404
	
	try:
		event = Event.objects.get(start_date=date, slug__iexact=slug)
	except IndexError:
		raise Http404
	
	icalendar = export_ical([event, ])
	
	response = HttpResponse(icalendar.as_string(), mimetype="text/calendar")
	response['Content-Disposition'] = 'attachment: filename=%s-%s.ics' % (event.start_date.isoformat(), event.slug)
	
	return response