Beispiel #1
0
    def vcard_view(self, REQUEST, RESPONSE):
        """vCard 3.0 output
        """
        RESPONSE.setHeader('Content-Type', 'text/x-vcard')
        RESPONSE.setHeader('Content-Disposition',
                           'attachment; filename="%s.vcf"' % self.getId())
        out = StringIO()

        # Get the fields using the accessors, so they're properly Unicode encoded.
        out.write("BEGIN:VCARD\nVERSION:3.0\n")
        out.write("FN:%s\n" % self.Title())
        out.write("N:%s;%s\n" % (self.getLastName(), self.getFirstName()))
        out.write(foldLine("TITLE:%s\n" % '\\n'.join(self.getJobTitles())))
        out.write(
            foldLine("ADR;TYPE=dom,postal,parcel,work:;;%s;%s;%s;%s\n" %
                     (self.getOfficeAddress().replace(
                         '\r\n', '\\n'), self.getOfficeCity(),
                      self.getOfficeState(), self.getOfficePostalCode())))
        out.write("TEL;WORK:%s\n" % self.getOfficePhone())
        out.write("EMAIL;TYPE=internet:%s\n" % self.getEmail())

        #Add the Person page to the list of URLs
        urls = list(self.getWebsites())
        urls.append(self.absolute_url())
        for url in urls:
            out.write(foldLine("URL:%s\n" % url))
        if self.getImage():
            encData = self.image_thumb.data.encode('base-64')
            # indent the data block:
            indentedData = '\n  '.join(encData.strip().split('\n'))
            out.write("PHOTO;ENCODING=BASE64;TYPE=JPEG:\n  %s\n" %
                      indentedData)
        out.write("REV:%s\n" % DateTime(self.ModificationDate()).ISO8601())
        out.write("PRODID:WebLion Faculty/Staff Directory\nEND:VCARD")
        return n2rn(out.getvalue())
Beispiel #2
0
    def vcard_view(self, REQUEST, RESPONSE):
        """vCard 3.0 output
        """
        RESPONSE.setHeader('Content-Type', 'text/x-vcard')
        RESPONSE.setHeader('Content-Disposition', 'attachment; filename="%s.vcf"' % self.getId())
        out = StringIO()

        # Get the fields using the accessors, so they're properly Unicode encoded.
        out.write("BEGIN:VCARD\nVERSION:3.0\n")
        out.write("FN:%s\n" % self.Title())
        out.write("N:%s;%s\n" % (self.getLastName(), self.getFirstName()))
        out.write(foldLine("TITLE:%s\n" % '\\n'.join(self.getJobTitles())))
        out.write(foldLine("ADR;TYPE=dom,postal,parcel,work:;;%s;%s;%s;%s\n" % (self.getOfficeAddress().replace('\r\n','\\n'), self.getOfficeCity(), self.getOfficeState(), self.getOfficePostalCode())))
        out.write("TEL;WORK:%s\n" % self.getOfficePhone())
        out.write("EMAIL;TYPE=internet:%s\n" % self.getEmail())

        #Add the Person page to the list of URLs
        urls = list(self.getWebsites())
        urls.append(self.absolute_url())
        for url in urls:
            out.write(foldLine("URL:%s\n" % url))
        if self.getImage():
            encData = self.image_thumb.data.encode('base-64')
            # indent the data block:
            indentedData = '\n  '.join(encData.strip().split('\n'))
            out.write("PHOTO;ENCODING=BASE64;TYPE=JPEG:\n  %s\n" % indentedData)
        out.write("REV:%s\n" % DateTime(self.ModificationDate()).ISO8601())
        out.write("PRODID:WebLion Faculty/Staff Directory\nEND:VCARD")
        return n2rn(out.getvalue())
Beispiel #3
0
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()
Beispiel #4
0
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 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 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()
Beispiel #7
0
    def getICal(self):
        """get iCal data
        """
        context = self.context
        out = StringIO()
        map = {
            'dtstamp': rfc2445dt(DateTime()),
            'created': rfc2445dt(DateTime(context.CreationDate())),
            'uid': IUUID(context),
            'modified': rfc2445dt(DateTime(context.ModificationDate())),
            'summary': vformat(context.Title()),
            'startdate': rfc2445dt(context.start_date),
            'enddate': rfc2445dt(context.end_date),
        }
        out.write(ICS_EVENT_START % map)

        description = context.Description()
        if description:
            out.write(foldLine('DESCRIPTION:%s\n' % vformat(description)))

        location = context.location
        if location:
            location = location.encode('utf-8')
            out.write('LOCATION:%s\n' % vformat(location))

        cn = []
        contact = context.autoridade
        if contact:
            cn.append(contact)
        if cn:
            out.write('CONTACT:%s\n' % vformat(', '.join(cn)))

        url = context.absolute_url()
        if url:
            out.write('URL:%s\n' % url)

        out.write(ICS_EVENT_END)
        return out.getvalue()
Beispiel #8
0
    def getICal(self):
        """get iCal data
        """
        context = self.context
        out = StringIO()
        map = {
            'dtstamp': rfc2445dt(DateTime()),
            'created': rfc2445dt(DateTime(context.CreationDate())),
            'uid': IUUID(context),
            'modified': rfc2445dt(DateTime(context.ModificationDate())),
            'summary': vformat(context.Title()),
            'startdate': rfc2445dt(context.start_date),
            'enddate': rfc2445dt(context.end_date),
        }
        out.write(ICS_EVENT_START % map)

        description = context.Description()
        if description:
            out.write(foldLine('DESCRIPTION:%s\n' % vformat(description)))

        location = context.location
        if location:
            location = location.encode('utf-8')
            out.write('LOCATION:%s\n' % vformat(location))

        cn = []
        contact = context.autoridade
        if contact:
            cn.append(contact)
        if cn:
            out.write('CONTACT:%s\n' % vformat(', '.join(cn)))

        url = context.absolute_url()
        if url:
            out.write('URL:%s\n' % url)

        out.write(ICS_EVENT_END)
        return out.getvalue()
Beispiel #9
0
 def getVCal(self):
     """get vCal data
     """
     context = self.context
     out = StringIO()
     map = {
         'dtstamp': rfc2445dt(DateTime()),
         'created': rfc2445dt(DateTime(context.CreationDate())),
         'uid': IUUID(context),
         'modified': rfc2445dt(DateTime(context.ModificationDate())),
         'summary': vformat(context.Title()),
         'startdate': rfc2445dt(context.start_date),
         'enddate': rfc2445dt(context.end_date),
     }
     out.write(VCS_EVENT_START % map)
     description = context.Description()
     if description:
         out.write(foldLine('DESCRIPTION:%s\n' % vformat(description)))
     location = context.location
     if location:
         location = location.encode('utf-8')
         out.write('LOCATION:%s\n' % vformat(location))
     out.write(VCS_EVENT_END)
     return out.getvalue()
Beispiel #10
0
 def getVCal(self):
     """get vCal data
     """
     context = self.context
     out = StringIO()
     map = {
         'dtstamp': rfc2445dt(DateTime()),
         'created': rfc2445dt(DateTime(context.CreationDate())),
         'uid': IUUID(context),
         'modified': rfc2445dt(DateTime(context.ModificationDate())),
         'summary': vformat(context.Title()),
         'startdate': rfc2445dt(context.start_date),
         'enddate': rfc2445dt(context.end_date),
     }
     out.write(VCS_EVENT_START % map)
     description = context.Description()
     if description:
         out.write(foldLine('DESCRIPTION:%s\n' % vformat(description)))
     location = context.location
     if location:
         location = location.encode('utf-8')
         out.write('LOCATION:%s\n' % vformat(location))
     out.write(VCS_EVENT_END)
     return out.getvalue()
Beispiel #11
0
 def getVCal(self):
     """get vCal data
     """
     context = self.context
     out = StringIO()
     map = {
         "dtstamp": rfc2445dt(DateTime()),
         "created": rfc2445dt(DateTime(context.CreationDate())),
         "uid": IUUID(context),
         "modified": rfc2445dt(DateTime(context.ModificationDate())),
         "summary": vformat(context.Title()),
         "startdate": rfc2445dt(context.start_date),
         "enddate": rfc2445dt(context.end_date),
     }
     out.write(VCS_EVENT_START % map)
     description = context.Description()
     if description:
         out.write(foldLine("DESCRIPTION:%s\n" % vformat(description)))
     location = context.location
     if location:
         location = location.encode("utf-8")
         out.write("LOCATION:%s\n" % vformat(location))
     out.write(VCS_EVENT_END)
     return out.getvalue()
Beispiel #12
0
    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()
Beispiel #13
0
    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 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()