Пример #1
0
    def getCommonTalkInformation(cls, conference, plugin_name, plugin_option):
        """
        Returns a tuple of 3 lists:
        - List of talks (Contribution objects which are not in a Poster session)
        - List of webcast capable rooms, as a list of "locationName:roomName" strings
        - List of webcast-able talks (list of Contribution objects who take place in a webcast capable room)
        - List of not webcast-able talks (list of Contribution objects who do not take place in a webcast capable room)
        """

        #a talk is defined as a non-poster contribution
        filter = PosterFilterField(conference, False, False)
        talks = [cont for cont in conference.getContributionList() if filter.satisfies(cont)]

        #list of "locationName:roomName" strings
        capableRooms = CollaborationTools.getOptionValueRooms(plugin_name, plugin_option)

        roomFullNames = [r.locationName + ':' + r.getFullName() for r in capableRooms]
        roomNames = [r.locationName + ':' + r.name for r in capableRooms]

        #a webcast-able talk is defined as a talk talking place in a webcast-able room
        ableTalks = []
        unableTalks = []
        for t in talks:
            location = t.getLocation()
            room = t.getRoom()
            if location and room and (location.getName() + ":" + room.getName() in roomNames) and t.isScheduled():
                ableTalks.append(t)
            else:
                unableTalks.append(t)

        return (talks, roomFullNames, roomNames, ableTalks, unableTalks)
Пример #2
0
def getCommonTalkInformation(conference):
    """ Returns a tuple of 3 lists:
        -List of talks (Contribution objects which are not in a Poster session)
        -List of webcast capable rooms, as a list of "locationName:roomName" strings
        -List of webcast-able talks (list of Contribution objects who take place in a webcast capable room)
    """

    #a talk is defined as a non-poster contribution
    filter = PosterFilterField(conference, False, False)
    talks = [cont for cont in conference.getContributionList() if filter.satisfies(cont)]

    #list of "locationName:roomName" strings
    webcastCapableRooms = CollaborationTools.getOptionValueRooms('WebcastRequest', "webcastCapableRooms")
    wcRoomFullNames = [r.locationName + ':' + r.getFullName() for r in webcastCapableRooms]
    wcRoomNames = [r.locationName + ':' + r.name for r in webcastCapableRooms]

    #a webcast-able talk is defined as a talk talking place in a webcast-able room
    webcastAbleTalks = []
    for t in talks:
        location = t.getLocation()
        room = t.getRoom()
        if location and room and (location.getName() + ":" + room.getName() in wcRoomNames):
            webcastAbleTalks.append(t)

    return (talks, wcRoomFullNames, wcRoomNames, webcastAbleTalks)
Пример #3
0
def getCommonTalkInformation(conference):
    """ Returns a tuple of 3 lists:
        -List of talks (Contribution objects which are not in a Poster session)
        -List of webcast capable rooms, as a list of "locationName:roomName" strings
        -List of webcast-able talks (list of Contribution objects who take place in a webcast capable room)
    """

    #a talk is defined as a non-poster contribution
    filter = PosterFilterField(conference, False, False)
    talks = [
        cont for cont in conference.getContributionList()
        if filter.satisfies(cont)
    ]

    #list of "locationName:roomName" strings
    webcastCapableRooms = CollaborationTools.getOptionValue(
        'WebcastRequest', "webcastCapableRooms")

    #a webcast-able talk is defined as a talk talking place in a webcast-able room
    webcastAbleTalks = []
    for t in talks:
        location = t.getLocation()
        room = t.getRoom()
        if location and room and (location.getName() + ":" + room.getName()
                                  in webcastCapableRooms):
            webcastAbleTalks.append(t)

    return (talks, webcastCapableRooms, webcastAbleTalks)
Пример #4
0
def getTalks(conference, oneIsEnough=False, sort=False):
    """ oneIsEnough: the algorithm will stop at the first contribution found
                     it will then return a list with a single element
        sort: if True, contributions are sorted by start date (non scheduled contributions at the end)
    """
    talks = []
    filter = PosterFilterField(conference, False, False)
    for cont in conference.getContributionList():
        if filter.satisfies(cont):
            talks.append(cont)
            if oneIsEnough:
                break
    if sort and not oneIsEnough:
        talks.sort(key=Contribution.contributionStartDateForSort)

    return talks
Пример #5
0
def getTalks(conference, oneIsEnough = False, sort = False):
    """ oneIsEnough: the algorithm will stop at the first contribution found
                     it will then return a list with a single element
        sort: if True, contributions are sorted by start date (non scheduled contributions at the end)
    """
    talks = []
    filter = PosterFilterField(conference, False, False)
    for cont in conference.getContributionList():
        if filter.satisfies(cont):
            talks.append(cont)
            if oneIsEnough:
                break
    if sort and not oneIsEnough:
        talks.sort(key = Contribution.contributionStartDateForSort)

    return talks
Пример #6
0
    def getCommonTalkInformation(cls, conference, plugin_name, plugin_option):
        """
        Returns a tuple of 3 lists:
        - List of talks (Contribution objects which are not in a Poster session)
        - List of webcast capable rooms, as a list of "locationName:roomName" strings
        - List of webcast-able talks (list of Contribution objects who take place in a webcast capable room)
        - List of not webcast-able talks (list of Contribution objects who do not take place in a webcast capable room)
        """

        #a talk is defined as a non-poster contribution
        filter = PosterFilterField(conference, False, False)
        talks = [
            cont for cont in conference.getContributionList()
            if filter.satisfies(cont)
        ]

        #list of "locationName:roomName" strings
        capableRooms = CollaborationTools.getOptionValueRooms(
            plugin_name, plugin_option)

        roomFullNames = [
            r.location_name + ':' + r.full_name for r in capableRooms
        ]
        roomNames = [r.location_name + ':' + r.name for r in capableRooms]

        #a webcast-able talk is defined as a talk talking place in a webcast-able room
        ableTalks = []
        unableTalks = []
        for t in talks:
            location = t.getLocation()
            room = t.getRoom()
            if location and room and (location.getName() + ":" +
                                      room.getName()
                                      in roomNames) and t.isScheduled():
                ableTalks.append(t)
            else:
                unableTalks.append(t)

        return (talks, roomFullNames, roomNames, ableTalks, unableTalks)
Пример #7
0
def getTalks(conference, sort = False):
    """
    sort: if True, contributions are sorted by start date (non scheduled contributions
    at the end)
    """

    # Logger.get('RecMan').debug("in getTalks()")

    # max length for title string
    title_length = 39

    # recordable_events is my own list of tags for each recordable event
    # which will be used by the tpl file.
    recordable_events = []
    talks = []

    speaker_str = ""
    speaker_list = conference.getChairList()
    if speaker_list is not None:
        speaker_str = ", ".join(["%s %s"%(speaker.getFirstName(), speaker.getFamilyName()) for speaker in speaker_list])

    event_info = {}
    event_info["contId"] = ""
    event_info["speakers"]   = speaker_str
    event_info["type"]       = "conference"
    event_info["IndicoID"]   = generateIndicoID(conference = conference.getId(),
                                              session         = None,
                                              contribution    = None,
                                              subcontribution = None)
    event_info["title"]      = conference.getTitle()
    event_info["titleshort"] = truncateString(event_info["title"], 40)
    # this always comes first, so just pretend it's 0 seconds past the epoch
    event_info["date"]       = int(time.mktime(conference.getAdjustedStartDate().timetuple()))

    event_info["LOID"]       = ""
    event_info["IndicoLink"] = doesExistIndicoLink(conference)

    recordable_events.append(event_info)

    # Posters are contributions that are not recordable,
    # so filter them out here
    filter = PosterFilterField(conference, False, False)
    for contribution in conference.getContributionList():
        if filter.satisfies(contribution):
            talks.append(contribution)
            speaker_str = ""
            speaker_list = contribution.getSpeakerList()
            if speaker_list is not None:
                speaker_str = ", ".join(["%s %s"%(speaker.getFirstName(), speaker.getFamilyName()) for speaker in speaker_list])

            event_info = {}
            event_info["contId"] = contribution.getId()
            event_info["speakers"]   = speaker_str
            event_info["type"]       = "contribution"
            event_info["IndicoID"]   = generateIndicoID(conference = conference.getId(),
                                              session         = None,
                                              contribution    = contribution.getId(),
                                              subcontribution = None)
            event_info["title"]      = contribution.getTitle()
            event_info["titleshort"] = truncateString(event_info["title"], title_length)
            # Sometimes contributions are not scheduled, so they have no start date.
            # In this case assign it the value None, and it will be displayed
            # at the end of the list with the time value "not scheduled"
            if contribution.getAdjustedStartDate() is not None:
                event_info["date"]   = int(time.mktime(contribution.getAdjustedStartDate().timetuple()))
            else:
                event_info["date"]   = None

            event_info["LOID"]       = ""
            event_info["IndicoLink"] = doesExistIndicoLink(contribution)

            recordable_events.append(event_info)
            ctr_sc = 0
            for subcontribution in contribution.getSubContributionList():
                ctr_sc += 1
                event_info = {}
                event_info["contId"] = contribution.getId()
                speaker_str = ""
                speaker_list = subcontribution.getSpeakerList()

                if speaker_list is not None:
                    speaker_str = ", ".join(["%s %s"%(speaker.getFirstName(), speaker.getFamilyName()) for speaker in speaker_list])

                event_info["speakers"]   = speaker_str
                event_info["type"]       = "subcontribution"
                event_info["IndicoID"]   = generateIndicoID(conference = conference.getId(),
                                              session         = None,
                                              contribution    = contribution.getId(),
                                              subcontribution = subcontribution.getId())
                event_info["title"]      = subcontribution.getTitle()
                event_info["titleshort"] = truncateString(event_info["title"], title_length)
                # Subcontribution objects don't have start dates,
                # so get the owner contribution's start date
                # and add the counter ctr_sc so they appear in order
                if subcontribution.getOwner().getAdjustedStartDate() is not None:
                    event_info["date"]     = int(time.mktime(subcontribution.getOwner().getAdjustedStartDate().timetuple()) + ctr_sc)
                else:
                    event_info["date"]       = int(time.mktime(conference.getAdjustedStartDate().timetuple())) + ctr_sc
                event_info["LOID"]       = ""
                event_info["IndicoLink"] = doesExistIndicoLink(subcontribution)

                recordable_events.append(event_info)


    for session in conference.getSessionList():
        event_info = {}
        event_info["contId"] = ""
        event_info["speakers"] = ""
        event_info["type"]     = "session"
        event_info["IndicoID"] = generateIndicoID(conference = conference.getId(),
                                                  session         = session.getId(),
                                                  contribution    = None,
                                                  subcontribution = None)
        event_info["title"]      = session.getTitle()
        event_info["titleshort"] = truncateString(event_info["title"], title_length)
        # Get start time as seconds since the epoch so we can sort
        if session.getAdjustedStartDate() is not None:
            event_info["date"]   = int(time.mktime(session.getAdjustedStartDate().timetuple()))
        else:
            event_info["date"]   = None
        event_info["LOID"]       = ""
        event_info["IndicoLink"] = doesExistIndicoLink(session)

        recordable_events.append(event_info)

    # Get list of matching IndicoIDs and CDS records from CDS
    cds_indico_matches = getCDSRecords(conference.getId())
#    Logger.get('RecMan').debug('cds_indico_pending...')
    cds_indico_pending = MicalaCommunication.getCDSPending(conference.getId())

    # In case there are any records that were pending and are now appearing in CDS,
    # then update the micala database accordingly.
    MicalaCommunication.updateMicalaCDSExport(cds_indico_matches, cds_indico_pending)

#    Logger.get('RecMan').debug("cds_indico_matches: %s, cds_indico_pending: %s" % (cds_indico_matches, cds_indico_pending))
    for event_info in recordable_events:
        try:
            event_info["CDSID"]     = cds_indico_matches[event_info["IndicoID"]]
            event_info["CDSURL"]    = CollaborationTools.getOptionValue("RecordingManager", "CDSBaseURL") % event_info["CDSID"]
        except KeyError:
#            Logger.get('RecMan').debug("Following talk not in CDS: %s" % event_info["title"])
            if cds_indico_pending is not None and event_info["IndicoID"] in set(cds_indico_pending):
                event_info["CDSID"]  = 'pending'
                event_info["CDSURL"] = ""
            else:
                event_info["CDSID"]  = "none"
                event_info["CDSURL"] = ""

    # Get list of matching IndicoID's and LOIDs from the Micala database
    existing_matches = MicalaCommunication.getMatches(conference.getId())

    # insert any existing matches into the recordable_events array
    for talk in recordable_events:
        # Look up IndicoID in existing_matches dictionary
        try:
            matching_LOID = existing_matches[talk["IndicoID"]]
        # If not found, do nothing (talk["LOID"] should already be assigned to "" by default)
        except KeyError:
            pass
        # If there is a matching_LOID, assign it to talk["LOID"]
        else:
            talk["LOID"] = matching_LOID

    # Now that we have all the micala, CDS and IndicoLink info, set up the bg images
    for talk in recordable_events:
        talk["bg"]         = chooseBGColor(talk)

    # Format dates for each talk for pleasing display
    for talk in recordable_events:
        talk["date_nice"] = formatDate(talk["date"])

    # Next, sort the list of events by startDate for display purposes
    recordable_events.sort(startTimeCompare)

#    Logger.get('RecMan').debug('leaving getTalks()')

    return recordable_events
Пример #8
0
def getTalks(conference, sort=False):
    """
    sort: if True, contributions are sorted by start date (non scheduled contributions
    at the end)
    """

    # Logger.get('RecMan').debug("in getTalks()")

    # max length for title string
    title_length = 39

    # recordable_events is my own list of tags for each recordable event
    # which will be used by the tpl file.
    recordable_events = []
    talks = []

    speaker_str = ""
    speaker_list = conference.getChairList()
    if speaker_list is not None:
        speaker_str = ", ".join([
            "%s %s" % (speaker.getFirstName(), speaker.getFamilyName())
            for speaker in speaker_list
        ])

    event_info = {}
    event_info["contId"] = ""
    event_info["speakers"] = speaker_str
    event_info["type"] = "conference"
    event_info["IndicoID"] = generateIndicoID(conference=conference.getId(),
                                              session=None,
                                              contribution=None,
                                              subcontribution=None)
    event_info["title"] = conference.getTitle()
    event_info["titleshort"] = truncate(event_info["title"], 40)
    # this always comes first, so just pretend it's 0 seconds past the epoch
    event_info["date"] = int(
        time.mktime(conference.getAdjustedStartDate().timetuple()))

    event_info["LOID"] = ""
    event_info["IndicoLink"] = doesExistIndicoLink(conference)

    recordable_events.append(event_info)

    # Posters are contributions that are not recordable,
    # so filter them out here
    filter = PosterFilterField(conference, False, False)
    for contribution in conference.getContributionList():
        if filter.satisfies(contribution):
            talks.append(contribution)
            speaker_str = ""
            speaker_list = contribution.getSpeakerList()
            if speaker_list is not None:
                speaker_str = ", ".join([
                    "%s %s" % (speaker.getFirstName(), speaker.getFamilyName())
                    for speaker in speaker_list
                ])

            event_info = {}
            event_info["contId"] = contribution.getId()
            event_info["speakers"] = speaker_str
            event_info["type"] = "contribution"
            event_info["IndicoID"] = generateIndicoID(
                conference=conference.getId(),
                session=None,
                contribution=contribution.getId(),
                subcontribution=None)
            event_info["title"] = contribution.getTitle()
            event_info["titleshort"] = truncate(event_info["title"],
                                                title_length)
            # Sometimes contributions are not scheduled, so they have no start date.
            # In this case assign it the value None, and it will be displayed
            # at the end of the list with the time value "not scheduled"
            if contribution.getAdjustedStartDate() is not None:
                event_info["date"] = int(
                    time.mktime(
                        contribution.getAdjustedStartDate().timetuple()))
            else:
                event_info["date"] = None

            event_info["LOID"] = ""
            event_info["IndicoLink"] = doesExistIndicoLink(contribution)

            recordable_events.append(event_info)
            ctr_sc = 0
            for subcontribution in contribution.getSubContributionList():
                ctr_sc += 1
                event_info = {}
                event_info["contId"] = contribution.getId()
                speaker_str = ""
                speaker_list = subcontribution.getSpeakerList()

                if speaker_list is not None:
                    speaker_str = ", ".join([
                        "%s %s" %
                        (speaker.getFirstName(), speaker.getFamilyName())
                        for speaker in speaker_list
                    ])

                event_info["speakers"] = speaker_str
                event_info["type"] = "subcontribution"
                event_info["IndicoID"] = generateIndicoID(
                    conference=conference.getId(),
                    session=None,
                    contribution=contribution.getId(),
                    subcontribution=subcontribution.getId())
                event_info["title"] = subcontribution.getTitle()
                event_info["titleshort"] = truncate(event_info["title"],
                                                    title_length)
                # Subcontribution objects don't have start dates,
                # so get the owner contribution's start date
                # and add the counter ctr_sc so they appear in order
                if subcontribution.getOwner().getAdjustedStartDate(
                ) is not None:
                    event_info["date"] = int(
                        time.mktime(subcontribution.getOwner(
                        ).getAdjustedStartDate().timetuple()) + ctr_sc)
                else:
                    event_info["date"] = int(
                        time.mktime(conference.getAdjustedStartDate().
                                    timetuple())) + ctr_sc
                event_info["LOID"] = ""
                event_info["IndicoLink"] = doesExistIndicoLink(subcontribution)

                recordable_events.append(event_info)

    for session in conference.getSessionList():
        event_info = {}
        event_info["contId"] = ""
        event_info["speakers"] = ""
        event_info["type"] = "session"
        event_info["IndicoID"] = generateIndicoID(
            conference=conference.getId(),
            session=session.getId(),
            contribution=None,
            subcontribution=None)
        event_info["title"] = session.getTitle()
        event_info["titleshort"] = truncate(event_info["title"], title_length)
        # Get start time as seconds since the epoch so we can sort
        if session.getAdjustedStartDate() is not None:
            event_info["date"] = int(
                time.mktime(session.getAdjustedStartDate().timetuple()))
        else:
            event_info["date"] = None
        event_info["LOID"] = ""
        event_info["IndicoLink"] = doesExistIndicoLink(session)

        recordable_events.append(event_info)

    # Get list of matching IndicoIDs and CDS records from CDS
    cds_indico_matches = getCDSRecords(conference.getId())
    #    Logger.get('RecMan').debug('cds_indico_pending...')
    cds_indico_pending = MicalaCommunication.getCDSPending(conference.getId())

    # In case there are any records that were pending and are now appearing in CDS,
    # then update the micala database accordingly.
    MicalaCommunication.updateMicalaCDSExport(cds_indico_matches,
                                              cds_indico_pending)

    #    Logger.get('RecMan').debug("cds_indico_matches: %s, cds_indico_pending: %s" % (cds_indico_matches, cds_indico_pending))
    for event_info in recordable_events:
        try:
            event_info["CDSID"] = cds_indico_matches[event_info["IndicoID"]]
            event_info["CDSURL"] = CollaborationTools.getOptionValue(
                "RecordingManager", "CDSBaseURL") % event_info["CDSID"]
        except KeyError:
            #            Logger.get('RecMan').debug("Following talk not in CDS: %s" % event_info["title"])
            if cds_indico_pending is not None and event_info[
                    "IndicoID"] in set(cds_indico_pending):
                event_info["CDSID"] = 'pending'
                event_info["CDSURL"] = ""
            else:
                event_info["CDSID"] = "none"
                event_info["CDSURL"] = ""

    # Get list of matching IndicoID's and LOIDs from the Micala database
    existing_matches = MicalaCommunication.getMatches(conference.getId())

    # insert any existing matches into the recordable_events array
    for talk in recordable_events:
        # Look up IndicoID in existing_matches dictionary
        try:
            matching_LOID = existing_matches[talk["IndicoID"]]
        # If not found, do nothing (talk["LOID"] should already be assigned to "" by default)
        except KeyError:
            pass
        # If there is a matching_LOID, assign it to talk["LOID"]
        else:
            talk["LOID"] = matching_LOID

    # Now that we have all the micala, CDS and IndicoLink info, set up the bg images
    for talk in recordable_events:
        talk["bg"] = chooseBGColor(talk)

    # Format dates for each talk for pleasing display
    for talk in recordable_events:
        talk["date_nice"] = formatDate(talk["date"])

    # Next, sort the list of events by startDate for display purposes
    recordable_events.sort(startTimeCompare)

    #    Logger.get('RecMan').debug('leaving getTalks()')

    return recordable_events