def talkListText(cls, conf, talkList):
        text = []

        #we sort by start date
        talkList.sort(key = Contribution.contributionStartDateForSort)

        #we check is event is single day
        singleDayEvent = isSameDay(conf.getStartDate(), conf.getEndDate(), conf.getTimezone())

        for contribution in talkList:

            #1. speakers text
            speakerList = contribution.getSpeakerList()
            if speakerList:
                speakers = ', by ' + ", ".join([person.getFullName() for person in speakerList])
            else:
                speakers = ''

            #2. room and location text
            locationStr = MailTools.locationOrRoomToStr(contribution.getLocation())
            roomStr = MailTools.locationOrRoomToStr(contribution.getRoom())
            confLocationStr = MailTools.locationOrRoomToStr(conf.getLocation())
            confRoomStr = MailTools.locationOrRoomToStr(conf.getRoom())

            if locationStr == confLocationStr and roomStr == confRoomStr:
                locationText = ''
            else:
                if locationStr:
                    locationText = "Location: " + locationStr
                    if roomStr:
                        locationText += ', Room: ' + roomStr
                    else:
                        locationText += ', Room: not defined'
                else:
                    locationText = "Location: not defined"

                locationText = " (%s)" % locationText

            #3. dates text
            if not contribution.getStartDate():
                datesText = '(Not scheduled)'
            elif singleDayEvent and isSameDay(conf.getStartDate(), contribution.getStartDate(), conf.getTimezone()):
                datesText = formatTime(contribution.getAdjustedStartDate().time()) + ' (' + formatDuration(contribution.getDuration(), "hours_minutes") + ')'
            else:
                datesText = formatDateTime(contribution.getAdjustedStartDate(), showWeek = True) + ' (' + formatDuration(contribution.getDuration(), "hours_minutes") + ')'

            #4. returned result
            contributionLine = """•%s : <a href="%s">%s</a>%s (id: %s)%s""" % (
                datesText,
                urlHandlers.UHContributionDisplay.getURL(contribution),
                contribution.getTitle(),
                speakers,
                contribution.getId(),
                locationText
            )
            text.append(contributionLine)

        return text
 def talkListText(cls, conf, talkList):
     text = []
     
     #we sort by start date
     talkList.sort(key = Contribution.contributionStartDateForSort)
     
     #we check is event is single day
     singleDayEvent = isSameDay(conf.getStartDate(), conf.getEndDate(), conf.getTimezone())
     
     for contribution in talkList:
         
         #1. speakers text
         speakerList = contribution.getSpeakerList()
         if speakerList:
             speakers = ', by ' + ", ".join([person.getFullName() for person in speakerList])
         else:
             speakers = ''
         
         #2. room and location text
         locationStr = MailTools.locationOrRoomToStr(contribution.getLocation())
         roomStr = MailTools.locationOrRoomToStr(contribution.getRoom())
         confLocationStr = MailTools.locationOrRoomToStr(conf.getLocation())
         confRoomStr = MailTools.locationOrRoomToStr(conf.getRoom())
         
         if locationStr == confLocationStr and roomStr == confRoomStr:
             locationText = ''
         else:
             if locationStr:
                 locationText = "Location: " + locationStr
                 if roomStr:
                     locationText += ', Room: ' + roomStr
                 else:
                     locationText += ', Room: not defined'
             else:
                 locationText = "Location: not defined"
             
             locationText = " (%s)" % locationText
             
         #3. dates text
         if not contribution.getStartDate():
             datesText = '(Not scheduled)'
         elif singleDayEvent and isSameDay(conf.getStartDate(), contribution.getStartDate(), conf.getTimezone()):
             datesText = formatTime(contribution.getAdjustedStartDate().time()) + ' (' + formatDuration(contribution.getDuration(), "hours_minutes") + ')'
         else:
             datesText = formatDateTime(contribution.getAdjustedStartDate(), showWeek = True) + ' (' + formatDuration(contribution.getDuration(), "hours_minutes") + ')'
             
         #4. returned result
         contributionLine = """•%s : <a href="%s">%s</a>%s (id: %s)%s""" % (
             datesText,
             urlHandlers.UHContributionDisplay.getURL(contribution),
             contribution.getTitle(),
             speakers,
             contribution.getId(),
             locationText
         )
         text.append(contributionLine)
     
     return text
Exemple #3
0
    def getVars(self):
        vars = WJSBase.getVars( self )

        if self._conf:
            vars["ConferenceId"] = self._conf.getId()
            vars["NumberOfContributions"] = self._conf.getNumberOfContributions()

            # these 2 vars are used to see if contrib dates shown should include day or just time
            vars["ConfStartDate"] = Conversion.datetime(self._conf.getAdjustedStartDate())
            vars["IsMultiDayEvent"] = not isSameDay(self._conf.getStartDate(), self._conf.getEndDate(), self._conf.getTimezone())

            location = ""
            if self._conf.getLocation() and self._conf.getLocation().getName():
                location = self._conf.getLocation().getName().strip()
            vars["ConfLocation"] = location

            room = ""
            if self._conf.getRoom() and self._conf.getRoom().getName():
                room = self._conf.getRoom().getName().strip()
            vars["ConfRoom"] = room

        else:
            # this is so that template can still be rendered in indexes page...
            # if necessary, we should refactor the Extra.js code so that it gets the
            # conference data from the booking, now that the booking has the conference inside
            vars["ConferenceId"] = ""
            vars["NumberOfContributions"] = 0
            vars["ConfStartDate"] = ""
            vars["IsMultiDayEvent"] = False
            vars["ConfLocation"] = ""
            vars["ConfRoom"] = ""

        return vars
Exemple #4
0
    def getVars(self):
        vars = WJSBase.getVars( self )    
        
        if self._conf:
            vars["ConferenceId"] = self._conf.getId()
            vars["NumberOfContributions"] = self._conf.getNumberOfContributions()

            # these 2 vars are used to see if contrib dates shown should include day or just time
            vars["ConfStartDate"] = Conversion.datetime(self._conf.getAdjustedStartDate())
            vars["IsMultiDayEvent"] = not isSameDay(self._conf.getStartDate(), self._conf.getEndDate(), self._conf.getTimezone())
            
            location = ""
            if self._conf.getLocation() and self._conf.getLocation().getName():
                location = self._conf.getLocation().getName().strip()
            vars["ConfLocation"] = location
            
            room = ""
            if self._conf.getRoom() and self._conf.getRoom().getName():
                room = self._conf.getRoom().getName().strip()
            vars["ConfRoom"] = room

        else:
            # this is so that template can still be rendered in indexes page...
            # if necessary, we should refactor the Extra.js code so that it gets the
            # conference data from the booking, now that the booking has the conference inside
            vars["ConferenceId"] = ""
            vars["NumberOfContributions"] = 0
            vars["ConfStartDate"] = ""
            vars["IsMultiDayEvent"] = False
            vars["ConfLocation"] = ""
            vars["ConfRoom"] = ""
        
        return vars
Exemple #5
0
def formatTwoDates(date1, date2, tz = None, useToday = False, useTomorrow = False, dayFormat = None, capitalize = True, showWeek = False):
    """ Formats two dates, such as an event start and end date, taking into account if they happen the same day
        (given a timezone).
        -date1 and date2 have to be timezone-aware.
        -If no tz argument is provided, tz will be the timezone of date1.
         tz can be a string or a timezone "object"
        -dayFormat and showWeek are passed to formatDate function, so they behave the same way as in that function
        -capitalize: capitalize week days AND first letter of sentence if there is one

        Examples: 17/07/2009 from 08:00 to 18:00 (default args, 2 dates in same day)
                  from 17/07/2009 at 08:00 to 19/07/2009 at 14:00 (default args, 2 dates in different day)
                  Fri 17/07/2009 from 08:00 to 18:00 (showWeek = True, default args, 2 dates in same day)
                  today from 10:00 to 11:00 (useToday = True, default args, 2 dates in same day and it happens to be today)
    """

    if not tz:
        tz = date1.tzinfo

    date1 = getAdjustedDate(date1, tz = tz)
    date2 = getAdjustedDate(date2, tz = tz)

    sameDay = isSameDay(date1, date2, tz)

    date1text = ''
    date2text = ''
    if useToday:
        if isToday(date1, tz):
            date1text = "today"
        if isToday(date2, tz):
            date2text = "today"
    if useTomorrow:
        if isTomorrow(date1, tz):
            date1text = "isTomorrow"
        if isTomorrow(date2, tz):
            date2text = "isTomorrow"


    if not date1text:
        date1text = formatDate(date1.date(), showWeek, dayFormat)
        if capitalize:
            date1text = date1text.capitalize()
    if not date2text:
        date2text = formatDate(date2.date(), showWeek, dayFormat)
        if capitalize:
            date2text = date2text.capitalize()

    time1text = formatTime(date1.time())
    time2text = formatTime(date2.time())

    if sameDay:
        result = date1text + ' from ' + time1text + ' to ' + time2text
    else:
        if capitalize:
            fromText = 'From '
        else:
            fromText = 'from '
        result = fromText + date1text + ' at ' + time1text + ' to ' + date2text + ' at ' + time2text

    return result
Exemple #6
0
def formatTwoDates(date1, date2, tz = None, useToday = False, useTomorrow = False, dayFormat = None, capitalize = True, showWeek = False):
    """ Formats two dates, such as an event start and end date, taking into account if they happen the same day
        (given a timezone).
        -date1 and date2 have to be timezone-aware.
        -If no tz argument is provided, tz will be the timezone of date1.
         tz can be a string or a timezone "object"
        -dayFormat and showWeek are passed to formatDate function, so they behave the same way as in that function
        -capitalize: capitalize week days AND first letter of sentence if there is one
        
        Examples: 17/07/2009 from 08:00 to 18:00 (default args, 2 dates in same day)
                  from 17/07/2009 at 08:00 to 19/07/2009 at 14:00 (default args, 2 dates in different day)
                  Fri 17/07/2009 from 08:00 to 18:00 (showWeek = True, default args, 2 dates in same day)
                  today from 10:00 to 11:00 (useToday = True, default args, 2 dates in same day and it happens to be today)
    """
    
    if not tz:
        tz = date1.tzinfo
    
    date1 = getAdjustedDate(date1, tz = tz)
    date2 = getAdjustedDate(date2, tz = tz)
    
    sameDay = isSameDay(date1, date2, tz)
    
    date1text = ''
    date2text = ''
    if useToday:
        if isToday(date1, tz):
            date1text = "today"
        if isToday(date2, tz):
            date2text = "today"
    if useTomorrow:
        if isTomorrow(date1, tz):
            date1text = "isTomorrow"
        if isTomorrow(date2, tz):
            date2text = "isTomorrow"
            
    
    if not date1text:
        date1text = formatDate(date1.date(), showWeek, dayFormat)
        if capitalize:
            date1text = date1text.capitalize()
    if not date2text:
        date2text = formatDate(date2.date(), showWeek, dayFormat)
        if capitalize:
            date2text = date2text.capitalize()
    
    time1text = formatTime(date1.time())
    time2text = formatTime(date2.time())
        
    if sameDay:
        result = date1text + ' from ' + time1text + ' to ' + time2text
    else:
        if capitalize:
            fromText = 'From '
        else:
            fromText = 'from '
        result = fromText + date1text + ' at ' + time1text + ' to ' + date2text + ' at ' + time2text
    
    return result