Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def item_organizer(self, obj):
organizer_dic = obj.get('organizer', None)
if organizer_dic:
if isinstance(organizer_dic, dict):
organizer = icalendar.vCalAddress('MAILTO:%s' % organizer_dic['email'])
for key, val in organizer_dic.items():
if key is not 'email':
organizer.params[key] = icalendar.vText(val)
else:
organizer = icalendar.vCalAddress('MAILTO:%s' % organizer_dic)
return organizer
event.add('dtstart', obj['when'].date())
else:
continue
event.add('summary', summary)
end = obj.get('end')
if not end:
end = obj['when'] + datetime.timedelta(hours=1)
event.add('dtend', end)
event.add('location', obj.get('location', 'Unknown'))
event['uid'] = obj['_id']
for participant in obj['participants']:
addr = icalendar.vCalAddress('MAILTO:noone@example.com')
cn = participant['participant']
if participant['type'] == 'committee':
cn += ' Committee'
addr.params['cn'] = icalendar.vText(cn)
#addr.params['ROLE'] = icalendar.vText('COMMITTEE')
event.add('attendee', addr, encode=0)
event['organizer'] = addr
cal.add_component(event)
return cal.as_string()
def matchAddress2vcal(self, address):
return icalendar.vCalAddress("MAILTO:%s" % self.matchAddress(address) )
continue
cal_event = icalendar.Event()
cal_event.add('uid', u'UID:event-%s-%s@kiberpipa.org' % (e.id, e.slug))
cal_event.add('summary', u'%s: %s' % (e.project, e.title))
cal_event.add('url', u'https://www.kiberpipa.org%s' % e.get_absolute_url())
cal_event.add('location', e.place.name)
cal_event.add('classification', classification)
cal_event.add('categories', u','.join([e.project.name, e.category.name]))
# http://www.kanzaki.com/docs/ical/transp.html
cal_event.add('transp', 'OPAQUE')
# dtstamp means when was the last time icalendar feed has changed
cal_event.add('dtstamp', ljubljana_tz.localize(datetime.datetime.now()))
cal_event.add('dtstart', ljubljana_tz.localize(e.start_date))
cal_event.add('dtend', ljubljana_tz.localize(e.end_date))
cal_event.add('last-modified', ljubljana_tz.localize(e.chg_date))
organizer = icalendar.vCalAddress(u'MAILTO:info@kiberpipa.org')
organizer.params['cn'] = u'Kiberpipa'
cal_event.add('organizer', organizer)
cal.add_component(cal_event)
response = HttpResponse(mimetype='text/calendar; charset=UTF-8')
response.write(cal.to_ical())
return response
event['uid'] = '20050115T101010/27346262376@mxm.dk'
event.add('priority', 5)
#event.add('attendee', 'mailto:argo@roots.ee')
attendee = vCalAddress('MAILTO:argo.roots@artun.ee')
attendee.params['cn'] = vText('Argo Roots')
attendee.params['ROLE'] = vText('CHAIR')
event.add('attendee', attendee, encode=0)
attendee = vCalAddress('MAILTO:mihkel.putrinsh@artun.ee')
attendee.params['cn'] = vText('Mihkel Putrinsh')
attendee.params['ROLE'] = vText('REQ-PARTICIPANT')
event.add('attendee', attendee, encode=0)
attendee = vCalAddress('MAILTO:maxm3@example.com')
attendee.params['cn'] = vText('Max Rasmussen 3')
attendee.params['ROLE'] = vText('OPT-PARTICIPANT')
#event.add('attendee', attendee, encode=0)
attendee = vCalAddress('MAILTO:maxm4@example.com')
attendee.params['cn'] = vText('Non')
attendee.params['ROLE'] = vText('NON-PARTICIPANT')
#event.add('attendee', attendee, encode=0)
cal.add_component(event)
event = Event()
event.add('summary', 'Python meeting about calendaring 2')
event.add('dtstart', date(2011,4,6))
event.add('dtend', date(2011,4,6))
event.add('dtstamp', datetime(2011,4,4,0,10,0,tzinfo=UTC))
event['uid'] = obj['_id']
status = obj.get('status')
if status:
event.add('status', status.upper())
notes = obj.get('notes')
if notes:
event.add('description', notes)
link = obj.get('link')
if link:
event.add('attach', link)
for participant in obj['participants']:
addr = icalendar.vCalAddress('MAILTO:noone@example.com')
chamber = participant.get('chamber')
if chamber:
cn = chamber_name(obj[obj['level']], chamber) + " "
else:
cn = ""
cn += participant['participant']
if participant['type'] == 'committee':
cn += ' Committee'
addr.params['cn'] = icalendar.vText(cn)
#addr.params['ROLE'] = icalendar.vText('COMMITTEE')
event.add('attendee', addr, encode=0)
event['organizer'] = addr
event_component = icalendar.Event()
event_component.add('summary', session.title)
event_component.add('uid', str(session.id) + "-" + event.identifier)
event_component.add('geo', (event.latitude, event.longitude))
event_component.add('location', session.microlocation.name or '' + " " + event.location_name)
event_component.add('dtstart', tz.localize(session.starts_at))
event_component.add('dtend', tz.localize(session.ends_at))
event_component.add('email', event.email)
event_component.add('description', session.short_abstract)
event_component.add('url', url_for('event_detail.display_event_detail_home',
identifier=event.identifier, _external=True))
for speaker in session.speakers:
# Ref: http://icalendar.readthedocs.io/en/latest/usage.html#file-structure
# can use speaker.email below but privacy reasons
attendee = vCalAddress('MAILTO:' + event.email if event.email else 'undefined@email.com')
attendee.params['cn'] = vText(speaker.name)
event_component.add('attendee', attendee)
cal.add_component(event_component)
return cal.to_ical()
def item_organizer(self, item):
"""Get item organizer."""
organizer = item.timesheet.user.email
organizer = vCalAddress(organizer)
organizer.params["CN"] = str(item.timesheet.user)
return organizer