Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
now = tz.localize(_now)
if term_id in self.courses:
for i in self.courses[term_id]:
for t in i.time:
for n, w in enumerate(t['week'][1:]):
if int(w):
targetTime = datetime.timedelta(days=7 * n + t['weekday']) + the_first_day + CLASS[
min(t['time'])]
targetEndTime = datetime.timedelta(days=7 * n + t['weekday'], minutes=45) + the_first_day + \
CLASS[max(t['time'])]
e = icalendar.Event()
e.add('dtstart', tz.localize(targetTime))
e.add('dtend', tz.localize(targetEndTime))
e['summary'] = "{} {} {}".format(i.name.split('(')[0],
i.teacher + "老师" if i.teacher else "", t['location'])
e['location'] = icalendar.vText(t['location'])
# e['SEQUENCE'] = 1
e['TRANSP'] = icalendar.vText('OPAQUE')
e['status'] = 'confirmed'
e.add('created', now)
e.add('DTSTAMP', _now)
e["UID"] = '{}@sync.pandada8.me'.format(md5(str(targetTime) + i.name))
e.add('LAST-MODIFIED', _now)
table.add_component(e)
return table
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'] = '20110115T101010/27346262376@mxm.dk'
event.add('priority', 5)
attendee = vCalAddress('MAILTO:mihkel.putrinsh@artun.ee')
attendee.params['cn'] = vText('Mihkel Putrinsh')
attendee.params['ROLE'] = vText('REQ-PARTICIPANT')
def add_attendee(self, email, cn=None, rsvp=True):
"""
Add an attendee to the event. If the event is being sent via an email,
the recipient should be added as an attendee.
:param str email: The attendee's email address.
:param str cn: The attendee's common name.
:param bool rsvp: Whether or not to request an RSVP response from the
attendee.
"""
attendee = icalendar.vCalAddress('MAILTO:' + email)
attendee.params['ROLE'] = icalendar.vText('REQ-PARTICIPANT')
attendee.params['PARTSTAT'] = icalendar.vText('NEEDS-ACTION')
attendee.params['RSVP'] = icalendar.vText(str(bool(rsvp)).upper())
attendee.params['CN'] = icalendar.vText(cn or email)
self._event.add('attendee', attendee)
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 add_attendee(self, email, cn=None, rsvp=True):
"""
Add an attendee to the event. If the event is being sent via an email,
the recipient should be added as an attendee.
:param str email: The attendee's email address.
:param str cn: The attendee's common name.
:param bool rsvp: Whether or not to request an RSVP response from the
attendee.
"""
attendee = icalendar.vCalAddress('MAILTO:' + email)
attendee.params['ROLE'] = icalendar.vText('REQ-PARTICIPANT')
attendee.params['PARTSTAT'] = icalendar.vText('NEEDS-ACTION')
attendee.params['RSVP'] = icalendar.vText(str(bool(rsvp)).upper())
attendee.params['CN'] = icalendar.vText(cn or email)
self._event.add('attendee', attendee)
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'] = '20110115T101010/27346262376@mxm.dk'
event.add('priority', 5)
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)
cal.add_component(event)
self.echo(str(cal), False)
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()
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
cal.add_component(event)
return cal.as_string()
event.add("dtstart", post_election.election.start_time)
event.add("dtend", post_election.election.end_time)
event.add(
"DESCRIPTION",
"Find out more at {}/elections/{}/".format(
settings.CANONICAL_URL, postcode.replace(" ", "")
),
)
if polling_station.get("polling_station_known"):
geometry = polling_station["polling_station"]["geometry"]
if geometry:
event["geo"] = "{};{}".format(
geometry["coordinates"][0], geometry["coordinates"][1]
)
properties = polling_station["polling_station"]["properties"]
event["location"] = vText(
"{}, {}".format(
properties["address"].replace("\n", ", "),
properties["postcode"],
)
)
cal.add_component(event)
return HttpResponse(cal.to_ical(), content_type="text/calendar")
def duplicate(self):
"""duplicate this event's PROTO event
:rtype: Event
"""
new_uid = generate_random_uid()
vevent = self._vevents['PROTO'].copy()
vevent['SEQUENCE'] = 0
vevent['UID'] = icalendar.vText(new_uid)
vevent['SUMMARY'] = icalendar.vText(vevent['SUMMARY'] + ' Copy')
event = self.fromVEvents([vevent])
event.calendar = self.calendar
event._locale = self._locale
return event