def emGetICal(self, obj): """get iCal data """ out = StringIO() map = { "dtstamp": rfc2445dt(DateTime()), "created": rfc2445dt(DateTime(obj.CreationDate())), "uid": IUUID(obj), "modified": rfc2445dt(DateTime(obj.ModificationDate())), "summary": vformat(obj.title), "startdate": rfc2445dt(DateTime(obj.start)), "enddate": rfc2445dt(DateTime(obj.end)), } out.write(ICS_EVENT_START % map) description = obj.description if description: out.write(foldLine("DESCRIPTION:%s\n" % vformat(description))) location = obj.location if location: out.write("LOCATION:%s\n" % vformat(location)) url = obj.absolute_url() if url: out.write("URL:%s\n" % url) out.write(ICS_EVENT_END) return out.getvalue()
def get_ical(result): """get iCal data """ out = StringIO() map = { 'dtstamp': rfc2445dt(DateTime()), 'created': rfc2445dt(DateTime(result.CreationDate())), 'uid': result.UID(), 'modified': rfc2445dt(DateTime(result.ModificationDate())), 'summary': vformat(result.Title()), 'startdate': rfc2445dt(result.start()), 'enddate': rfc2445dt(result.end()), } out.write(ICS_EVENT_START % map) description = result.Description() if description: out.write(foldLine('DESCRIPTION:%s\n' % vformat(description))) subject = result.Subject() if subject: out.write('CATEGORIES:%s\n' % ', '.join(subject)) out.write(ICS_EVENT_END) return out.getvalue()
def getICal(self): """get iCal data """ out = StringIO() map = { 'dtstamp' : rfc2445dt(DateTime()), 'created' : rfc2445dt(DateTime(self.CreationDate())), 'uid' : self.UID(), 'modified' : rfc2445dt(DateTime(self.ModificationDate())), 'summary' : vformat(self.Title()), 'startdate' : rfc2445dt(self.start()), 'enddate' : rfc2445dt(self.end()), } out.write(ICS_EVENT_START % map) description = self.Description() if description: out.write(foldLine('DESCRIPTION:%s\n' % vformat(description))) subject = self.Subject() if subject: out.write('CATEGORIES:%s\n' % ','.join(subject)) # TODO -- NO! see the RFC; ORGANIZER field is not to be used for non-group-scheduled entities #ORGANIZER;CN=%(name):MAILTO=%(email) #ATTENDEE;CN=%(name);ROLE=REQ-PARTICIPANT:mailto:%(email) cn = [] mtool = getToolByName(self, 'portal_membership') human_resources = self.getMHumanRessources() if len(human_resources) > 0: human_resouce = human_resources[0] user_id = human_resouce.split(':')[0] user = mtool.getMemberById(user_id) contact_name = user.getProperty('fullname', user_id) cn.append(contact_name) contact_phone = user.getProperty('phone', '') if contact_phone: cn.append('') email = user.getProperty('email', '') if email: cn.append(email) out.write('CONTACT:%s\n' % vformat(', '.join(cn))) url = self.absolute_url() out.write('URL:%s\n' % url) out.write(ICS_EVENT_END) return out.getvalue()
def feeddata(self): context = self.context data = cs.ICS_HEADER % dict(prodid=cs.PRODID) data += 'DTSTAMP:%s\n' % cs.rfc2445dt(DateTime()) data += 'CREATED:%s\n' % cs.rfc2445dt(DateTime(context.CreationDate())) data += 'UID:ATEvent-%s\n' % self.context.UID() data += 'LAST-MODIFIED:%s\n' % cs.rfc2445dt(DateTime(context.ModificationDate())) data += 'SUMMARY:%s\n' % cs.vformat(context.Title()) data += 'DESCRIPTION:%s\n' % cs.vformat(context.Description()) # data += 'CONTACT:%s\n' % cs.vformat(context.contact_name()) # data += 'LOCATION:%s\n' % cs.vformat(context.getLocation()) # data += 'DTSTART:%s\n' % cs.rfc2445dt((context.start()) # data += 'DTEND:%s\n' % cs.rfc2445dt(context.end()) for brain in self.events: data += brain.getObject().getICal() data += cs.ICS_FOOTER return data
def getICal(self): """get iCal data """ _start_date = self._smart_start_date() _end_date = self._smart_end_date() event_start = _start_date.date() event_end = _end_date.date() event_days = self.getDates() duration = (event_end - event_start).days intervals = [] interval = [] while (duration > 0): day = event_end - timedelta(days=duration) if day in event_days: if day == event_start: interval.append(_start_date) else: interval.append(day) else: if interval: intervals.append(interval) interval = [] duration = duration - 1 if event_end in event_days: interval.append(_end_date) if interval: intervals.append(interval) out = StringIO() for interval in intervals: startTime = interval[0] endTime = interval[-1] if not endTime == _end_date: endTime = datetime(endTime.year, endTime.month, endTime.day, 23, 59, 00) if not startTime == _start_date: startTime = datetime(startTime.year, startTime.month, startTime.day, 00, 00, 00) # if len(intervals) == 1: # startTime = self._start_date() map = { 'dtstamp': rfc2445dt(DateTime()), 'created': rfc2445dt(DateTime(self.CreationDate())), 'uid': self.UID() + utils.dstartformat(interval[0]), 'modified': rfc2445dt(DateTime(self.ModificationDate())), 'summary': vformat(self.Title()), 'startdate': rfc2445dt(utils.toDateTime(startTime)), 'enddate': rfc2445dt(utils.toDateTime(endTime)), } out.write(ICS_EVENT_START % map) description = self.Description() if description: out.write(foldLine('DESCRIPTION:%s\n' % vformat(description))) location = self.getLocation() if location: out.write('LOCATION:%s\n' % vformat(location)) eventType = self.getEventType() if eventType: out.write('CATEGORIES:%s\n' % ','.join(eventType)) # TODO -- NO! see the RFC; ORGANIZER field is not to be used for non-group-scheduled entities #ORGANIZER;CN=%(name):MAILTO=%(email) #ATTENDEE;CN=%(name);ROLE=REQ-PARTICIPANT:mailto:%(email) cn = [] contact = self.contact_name() if contact: cn.append(contact) phones = self.contact_phone() for phone in phones: cn.append(phone) emails = self.contact_email() for email in emails: cn.append(email) if cn: out.write('CONTACT:%s\n' % ', '.join(cn)) url = self.event_url() if url: out.write('URL:%s\n' % ', '.join(url)) out.write(ICS_EVENT_END) return out.getvalue()
def getVCal(self): """get vCal data """ _start_date = self._smart_start_date() _end_date = self._smart_end_date() event_start = _start_date.date() event_end = _end_date.date() event_days = self.getDates() duration = (event_end - event_start).days intervals = [] interval = [] while (duration > 0): day = event_end - timedelta(days=duration) if day in event_days: if day == event_start: interval.append(_start_date) else: interval.append(day) else: if interval: intervals.append(interval) interval = [] duration = duration - 1 if event_end in event_days: interval.append(_end_date) if interval: intervals.append(interval) out = StringIO() for interval in intervals: startTime = interval[0] endTime = interval[-1] if not endTime == _end_date: endTime = datetime(endTime.year, endTime.month, endTime.day, 23, 59, 00) if not startTime == _start_date: startTime = datetime(startTime.year, startTime.month, startTime.day, 00, 00, 00) # if len(intervals) == 1: # startTime = self._start_date() map = { 'dtstamp': rfc2445dt(DateTime()), 'created': rfc2445dt(DateTime(self.CreationDate())), 'uid': self.UID() + utils.dstartformat(interval[0]), 'modified': rfc2445dt(DateTime(self.ModificationDate())), 'summary': vformat(self.Title()), 'startdate': rfc2445dt(utils.toDateTime(startTime)), 'enddate': rfc2445dt(utils.toDateTime(endTime)), } out.write(VCS_EVENT_START % map) description = self.Description() if description: out.write(foldLine('DESCRIPTION:%s\n' % vformat(description))) location = self.getLocation() if location: out.write('LOCATION:%s\n' % vformat(location)) out.write(VCS_EVENT_END) return out.getvalue()
def getICal(self): """get iCal data """ out = StringIO() map = { 'dtstamp': rfc2445dt(DateTime()), 'created': rfc2445dt(DateTime(self.CreationDate())), 'uid': self.UID(), 'modified': rfc2445dt(DateTime(self.ModificationDate())), 'summary': vformat(self.Title()), 'startdate': rfc2445dt(self.start()), 'enddate': rfc2445dt(self.end()), } out.write(ICS_EVENT_START % map) description = self.Description() if description: out.write(foldLine('DESCRIPTION:%s\n' % vformat(description))) location = self.getLocation() if location: # PATCH: Grab the map_link field, and if it exists, append it to the # location. map_link = getattr(self, 'map_link', None) if map_link: out.write('LOCATION:%s ( %s )\n' % (vformat(location), map_link)) else: out.write('LOCATION:%s\n' % vformat(location)) subject = self.Subject() if subject: out.write('CATEGORIES:%s\n' % ', '.join(subject)) # TODO -- NO! see the RFC; ORGANIZER field is not to be used for non-group-scheduled entities #ORGANIZER;CN=%(name):MAILTO=%(email) #ATTENDEE;CN=%(name);ROLE=REQ-PARTICIPANT:mailto:%(email) cn = [] contact = self.contact_name() if contact: cn.append(contact) phone = self.contact_phone() if phone: cn.append(phone) email = self.contact_email() if email: cn.append(email) if cn: out.write('CONTACT:%s\n' % vformat(', '.join(cn))) url = self.event_url() # PATCH: If there's no event URL, try to grab the map_link field. # Fall back to the URL of the event object. if not url: url = getattr(self, 'map_link', None) if not url: url = self.absolute_url() if url: out.write('URL:%s\n' % url) out.write(ICS_EVENT_END) return out.getvalue()
def revision(self, object, value): return rfc2445dt(DateTime(object.ModificationDate()))
def getVCard(self): """ vCard """ VF = self._vf # shortcut out = StringIO() # extract the vcard relevant data through an IVCardData adapter adapter = IVCardData(self.context) data = adapter.getVCardData() # auf foldLine mit absicht verzichtet ... buggy is das adressbuch von # MacOS -> kann keine karte einlesen, in der foldline benutzt wird :( # NAME:Hans Mustermann Visitenkarte out.write('NAME:%s Vcard\n' % vformat(data['id'])) # SOURCE out.write('SOURCE:%s\n' % data['source']) # FN out.write('FN;LANGUAGE=de;CHARSET=%s:%s\n' % (to_encoding, VF(data['vcardname']))) # N:nachname;vorname;2.vorname;titel content = '%s;%s;;%s' % (VF(data['lastname']), VF(data['firstname']), VF(data['degree'])) out.write('N;LANGUAGE=de;CHARSET=%s:%s\n' % (to_encoding, content)) # SORT-STRING if data['lastname']: out.write('SORT-STRING:%s\n' % VF(data['lastname'])) # PHOTO (inline) if data['image']: encoded_data = base64.encodestring(data['image']) out.write('PHOTO;BASE64:\n') for line in encoded_data.split('\n'): out.write(' ' + line) out.write('\n') # EMAIL;TYPE=INTERNET if data['email']: out.write('EMAIL;TYPE=INTERNET:%s\n' % data['email']) # URL:http://de.wikipedia.org/ if data['url']: out.write('URL;WORK:%s\n' % data['url']) # TEL;TYPE=PREF;TYPE=WORK:030-1234567 if data['phone']: out.write('TEL;TYPE=PREF;TYPE=WORK:%s\n' % data['phone']) # TEL;TYPE=FAX:030-1234567 if data['fax']: out.write('TEL;TYPE=FAX:%s\n' % data['fax']) # TEL;TYPE=CELL:+49 1234 56789 if data['mobile']: out.write('TEL;TYPE=CELL:%s\n' % data['mobile']) # TITLE:SACHBEREICH # ROLE:FUNKTION) if data['position']: content = VF(data['position']) out.write('ROLE;LANGUAGE=de;CHARSET=%s:%s\n' % (to_encoding, content)) # ORG;LANGUAGE=de;CHARSET=utf-8:einrichtung if data['institution']: content = VF(data['institution']) out.write('ORG;LANGUAGE=de;CHARSET=%s:%s\n' % (to_encoding, content)) # REV:2007-01-03T11\:08\:23Z date_rev = rfc2445dt(DateTime()) out.write('REV:%s\n' % (vformat(date_rev) )) # NOTE aka Description if data['notes']: content = '%s\n' % VF(data['notes']) out.write('NOTE;LANGUAGE=de;CHARSET=%s:%s' % (to_encoding, content)) # addresses for i, row in enumerate(data.get('addresses', ())): content= '%s;;%s;%s;%s;%s;%s' % (VF(row['pobox']), VF(row['street']), VF(row['city']), VF(row['province']), VF(row['zipcode']), VF(row['country']) ) if i==0: out.write('ADR;CHARSET=%s;TYPE=pref,work:%s\n' % (to_encoding,content)) else: out.write('ADR;CHARSET=%s;TYPE=work:%s\n' % (to_encoding,content)) return out.getvalue()
def getICal(self): """get iCal data """ _start_date = self._smart_start_date() _end_date = self._smart_end_date() event_start = _start_date.date() event_end = _end_date.date() event_days = self.getDates() duration = (event_end - event_start).days intervals = [] interval = [] while(duration > 0): day = event_end - timedelta(days=duration) if day in event_days: if day == event_start: interval.append(_start_date) else: interval.append(day) else: if interval: intervals.append(interval) interval = [] duration = duration - 1 if event_end in event_days: interval.append(_end_date) if interval: intervals.append(interval) out = StringIO() for interval in intervals: startTime = interval[0] endTime = interval[-1] if not endTime == _end_date: endTime = datetime(endTime.year, endTime.month, endTime.day, 23, 59, 00) if not startTime == _start_date: startTime = datetime(startTime.year, startTime.month, startTime.day, 00, 00, 00) # if len(intervals) == 1: # startTime = self._start_date() map = { 'dtstamp' : rfc2445dt(DateTime()), 'created' : rfc2445dt(DateTime(self.CreationDate())), 'uid' : self.UID() + utils.dstartformat(interval[0]), 'modified' : rfc2445dt(DateTime(self.ModificationDate())), 'summary' : vformat(self.Title()), 'startdate' : rfc2445dt(utils.toDateTime(startTime)), 'enddate' : rfc2445dt(utils.toDateTime(endTime)), } out.write(ICS_EVENT_START % map) description = self.Description() if description: out.write(foldLine('DESCRIPTION:%s\n' % vformat(description))) location = self.getLocation() if location: out.write('LOCATION:%s\n' % vformat(location)) eventType = self.getEventType() if eventType: out.write('CATEGORIES:%s\n' % ','.join(eventType)) # TODO -- NO! see the RFC; ORGANIZER field is not to be used for non-group-scheduled entities #ORGANIZER;CN=%(name):MAILTO=%(email) #ATTENDEE;CN=%(name);ROLE=REQ-PARTICIPANT:mailto:%(email) cn = [] contact = self.contact_name() if contact: cn.append(contact) phones = self.contact_phone() for phone in phones: cn.append(phone) emails = self.contact_email() for email in emails: cn.append(email) if cn: out.write('CONTACT:%s\n' % ', '.join(cn)) url = self.event_url() if url: out.write('URL:%s\n' % ', '.join(url)) out.write(ICS_EVENT_END) return out.getvalue()
def getVCal(self): """get vCal data """ _start_date = self._smart_start_date() _end_date = self._smart_end_date() event_start = _start_date.date() event_end = _end_date.date() event_days = self.getDates() duration = (event_end - event_start).days intervals = [] interval = [] while(duration > 0): day = event_end - timedelta(days=duration) if day in event_days: if day == event_start: interval.append(_start_date) else: interval.append(day) else: if interval: intervals.append(interval) interval = [] duration = duration - 1 if event_end in event_days: interval.append(_end_date) if interval: intervals.append(interval) out = StringIO() for interval in intervals: startTime = interval[0] endTime = interval[-1] if not endTime == _end_date: endTime = datetime(endTime.year, endTime.month, endTime.day, 23, 59, 00) if not startTime == _start_date: startTime = datetime(startTime.year, startTime.month, startTime.day, 00, 00, 00) # if len(intervals) == 1: # startTime = self._start_date() map = { 'dtstamp' : rfc2445dt(DateTime()), 'created' : rfc2445dt(DateTime(self.CreationDate())), 'uid' : self.UID() + utils.dstartformat(interval[0]), 'modified' : rfc2445dt(DateTime(self.ModificationDate())), 'summary' : vformat(self.Title()), 'startdate' : rfc2445dt(utils.toDateTime(startTime)), 'enddate' : rfc2445dt(utils.toDateTime(endTime)), } out.write(VCS_EVENT_START % map) description = self.Description() if description: out.write(foldLine('DESCRIPTION:%s\n' % vformat(description))) location = self.getLocation() if location: out.write('LOCATION:%s\n' % vformat(location)) out.write(VCS_EVENT_END) return out.getvalue()