def render(self, **kwargs): url = get_base_url(self.event) context = { 'data': self.data, 'url': url, 'domain': urlparse(url).netloc } content = get_template('agenda/schedule.xcal').render(context=context) return f'{self.event.slug}.xcal', 'text/xml', content
def render(self, **kwargs): url = get_base_url(self.event) context = { "data": self.data, "url": url, "domain": urlparse(url).netloc } content = get_template("agenda/schedule.xcal").render(context=context) return f"{self.event.slug}.xcal", "text/xml", content
def render(self, **kwargs): context = { 'data': self.data, 'metadata': self.metadata, 'schedule': self.schedule, 'event': self.event, 'version': __version__, 'base_url': get_base_url(self.event), } content = get_template('agenda/schedule.xml').render(context=context) return f'{self.event.slug}-schedule.xml', 'text/xml', content
def render(self, **kwargs): context = { "data": self.data, "metadata": self.metadata, "schedule": self.schedule, "event": self.event, "version": __version__, "base_url": get_base_url(self.event), } content = get_template("agenda/schedule.xml").render(context=context) return f"{self.event.slug}-schedule.xml", "text/xml", content
def render(self, **kwargs): netloc = urlparse(get_base_url(self.event)).netloc cal = vobject.iCalendar() cal.add('prodid').value = '-//pretalx//{}//'.format(netloc) creation_time = datetime.now(pytz.utc) talks = (self.schedule.talks.filter(is_visible=True).prefetch_related( 'submission__speakers').select_related('submission', 'room').order_by('start')) for talk in talks: talk.build_ical(cal, creation_time=creation_time, netloc=netloc) return f'{self.event.slug}.ics', 'text/calendar', cal.serialize()
def render(self, **kwargs): netloc = urlparse(get_base_url(self.event)).netloc cal = vobject.iCalendar() cal.add("prodid").value = "-//pretalx//{}//".format(netloc) creation_time = dt.datetime.now(pytz.utc) talks = (self.schedule.talks.filter(is_visible=True).prefetch_related( "submission__speakers").select_related( "submission", "room", "submission__event").order_by("start")) for talk in talks: talk.build_ical(cal, creation_time=creation_time, netloc=netloc) return f"{self.event.slug}.ics", "text/calendar", cal.serialize()
def get(self, request, event, **kwargs): schedule = self.get_object() netloc = urlparse(get_base_url(request.event)).netloc cal = vobject.iCalendar() cal.add('prodid').value = '-//pretalx//{}//'.format(netloc) creation_time = datetime.now(pytz.utc) talks = schedule.talks.filter( is_visible=True ).prefetch_related('submission__speakers').select_related('submission', 'room').order_by('start') for talk in talks: talk.build_ical(cal, creation_time=creation_time, netloc=netloc) resp = HttpResponse(cal.serialize(), content_type='text/calendar') resp['Content-Disposition'] = f'attachment; filename="{request.event.slug}.ics"' return resp
def build_ical(self, calendar, creation_time=None, netloc=None): creation_time = creation_time or datetime.now(pytz.utc) netloc = netloc or urlparse(get_base_url(self.event)).netloc tz = pytz.timezone(self.submission.event.timezone) vevent = calendar.add('vevent') vevent.add('summary').value = f'{self.submission.title} - {self.submission.display_speaker_names}' vevent.add('dtstamp').value = creation_time vevent.add('location').value = str(self.room.name) vevent.add('uid').value = 'pretalx-{}-{}@{}'.format( self.submission.event.slug, self.submission.code, netloc ) vevent.add('dtstart').value = self.start.astimezone(tz) vevent.add('dtend').value = self.end.astimezone(tz) vevent.add('description').value = self.submission.abstract or "" vevent.add('url').value = self.submission.urls.public.full()
def build_ical(self, calendar, creation_time=None, netloc=None): if not self.start or not self.end or not self.room: return creation_time = creation_time or dt.datetime.now(pytz.utc) netloc = netloc or urlparse(get_base_url(self.event)).netloc tz = pytz.timezone(self.submission.event.timezone) vevent = calendar.add("vevent") vevent.add( "summary" ).value = f"{self.submission.title} - {self.submission.display_speaker_names}" vevent.add("dtstamp").value = creation_time vevent.add("location").value = str(self.room.name) vevent.add("uid").value = "pretalx-{}-{}@{}".format( self.submission.event.slug, self.submission.code, netloc) vevent.add("dtstart").value = self.start.astimezone(tz) vevent.add("dtend").value = self.end.astimezone(tz) vevent.add("description").value = self.submission.abstract or "" vevent.add("url").value = self.submission.urls.public.full()
def html_export_url(self) -> str: return get_base_url(self) + self.orga_urls.schedule_export_download
def get_context_data(self, *args, **kwargs): ctx = super().get_context_data(*args, **kwargs) url = get_base_url(self.request.event) ctx['url'] = url ctx['domain'] = urlparse(url).netloc return ctx