def render_event_email(event, email): """ Render event email subject and body. """ context = {} context['event_title'] = event.title context['event_date'] = format_datetime_range(event.start_dt, event.end_dt) context['event_location'] = '' if event.place: context['event_location'] += '<div><strong>Location</strong>:</div>' if event.place.name: context['event_location'] += '%s<br />' % event.place.name if event.place.address: context['event_location'] += '%s<br />' % event.place.address if event.place.city or event.place.state or event.place.zip: context['event_location'] += '%s %s %s' % ( event.place.city, event.place.state, event.place.zip) context['event_link'] = '<a href="%s">%s</a>' % ( reverse('event', args=[event.id]), event.title ) context = Context(context) template = Template(email.subject) email.subject = template.render(context) email.body = email.body.replace('event_location', 'event_location|safe') email.body = email.body.replace('event_link', 'event_link|safe') template = Template(email.body) email.body = template.render(context) return email
def render_event_email(event, email): """ Render event email subject and body. """ context = {} context['event_title'] = event.title context['event_date'] = format_datetime_range(event.start_dt, event.end_dt) context['event_location'] = '' if event.place: context['event_location'] += '<div><strong>Location</strong>:</div>' if event.place.name: context['event_location'] += '%s<br />' % event.place.name if event.place.address: context['event_location'] += '%s<br />' % event.place.address if event.place.city or event.place.state or event.place.zip: context['event_location'] += '%s %s %s' % ( event.place.city, event.place.state, event.place.zip) context['event_link'] = '<a href="%s">%s</a>' % (reverse( 'event', args=[event.id]), event.title) context = Context(context) template = Template(email.subject) email.subject = template.render(context) email.body = email.body.replace('event_location', 'event_location|safe') email.body = email.body.replace('event_link', 'event_link|safe') template = Template(email.body) email.body = template.render(context) return email
def dt_display(self, format_date='%a, %b %d, %Y', format_time='%I:%M %p'): from tendenci.core.base.utils import format_datetime_range return format_datetime_range(self.start_dt, self.end_dt, format_date, format_time)