def serve(self, request): if "format" in request.GET: if request.GET["format"] == "ical": # Export to ical format response = HttpResponse(export_event(self, "ical"), content_type="text/calendar") response["Content-Disposition"] = "attachment; filename=" + self.slug + ".ics" return response else: # Unrecognised format error message = "Could not export event\n\nUnrecognised format: " + request.GET["format"] return HttpResponse(message, content_type="text/plain") else: # Display event page as usual return super(EventPage, self).serve(request)
def serve(self, request): if "format" in request.GET: if request.GET['format'] == 'ical': # Export to ical format response = HttpResponse( export_event(self, 'ical'), content_type='text/calendar', ) response['Content-Disposition'] = 'attachment; filename=' + self.slug + '.ics' return response else: # Unrecognised format error message = 'Could not export event\n\nUnrecognised format: ' + request.GET['format'] return HttpResponse(message, content_type='text/plain') else: # Display event page as usual return super(EventPage, self).serve(request)