Exemple #1
0
class IConferenceMetadataFossil(_IncludeMaterialFossil, IFossil):

    def getId(self):
        pass

    def getStartDate(self):
        pass
    getStartDate.convert = Conversion.datetime

    def getEndDate(self):
        pass
    getEndDate.convert = Conversion.datetime

    def getTitle(self):
        pass

    def getDescription(self):
        pass

    def getType(self):
        pass

    def getOwner(self):
        pass
    getOwner.convert = lambda x: x.getTitle()
    getOwner.name = 'category'

    def getCategoryId(self):
        pass
    getCategoryId.produce = lambda x: x.getOwner().getId()

    def getTimezone(self):
        pass

    def getChairList(self):
        pass
    getChairList.name = 'chairs'
    getChairList.result = IConferenceChairMetadataFossil

    def getLocation(self):
        """ Location (CERN/...) """
    getLocation.convert = lambda l: l and l.getName()

    def getLocator(self):
        pass
    getLocator.convert = Conversion.url(urlHandlers.UHConferenceDisplay)
    getLocator.name = 'url'

    def getRoom(self):
        """ Room (inside location) """
    getRoom.convert = lambda r: r and r.getName()

    def getVisibility(self):
        pass
    getVisibility.name = 'visibility'
    getVisibility.produce = lambda x: Conversion.visibility(x)

    def getRoomMapURL(self):
        pass
    getRoomMapURL.produce = lambda x: RoomLinker().getURL(x.getRoom(), x.getLocation())
Exemple #2
0
    def _build_event_api_data(self, event):
        can_manage = self.user is not None and event.can_manage(self.user)
        data = self._build_event_api_data_base(event)
        data.update({
            '_fossil': self.fossils_mapping['event'].get(self._detail_level),
            'categoryId': unicode(event.category_id),
            'category': event.category.getTitle(),
            'note': build_note_api_data(event.note),
            'roomFullname': event.room_name,
            'url': url_for('event.conferenceDisplay', confId=event.id, _external=True),
            'modificationDate': self._serialize_date(event.as_legacy.getModificationDate()),
            'creationDate': self._serialize_date(event.as_legacy.getCreationDate()),
            'creator': self._serialize_person(event.creator, person_type='Avatar', can_manage=can_manage),
            'hasAnyProtection': event.as_legacy.hasAnyProtection(),
            'roomMapURL': event.room.map_url if event.room else None,
            'visibility': Conversion.visibility(event.as_legacy),
            'folders': build_folders_api_data(event),
            'chairs': self._serialize_persons(event.person_links, person_type='ConferenceChair', can_manage=can_manage),
            'material': build_material_legacy_api_data(event) + [build_note_legacy_api_data(event.note)]
        })
        if can_manage:
            data['allowed'] = self._serialize_access_list(event)
        if self._detail_level in {'contributions', 'subcontributions'}:
            data['contributions'] = []
            for contribution in event.contributions:
                include_subcontribs = self._detail_level == 'subcontributions'
                serialized_contrib = self._serialize_contribution(contribution, include_subcontribs)
                data['contributions'].append(serialized_contrib)
        elif self._detail_level == 'sessions':
            # Contributions without a session
            data['contributions'] = []
            for contribution in event.contributions:
                if not contribution.session:
                    serialized_contrib = self._serialize_contribution(contribution)
                    data['contributions'].append(serialized_contrib)

            data['sessions'] = []
            for session_ in event.sessions:
                data['sessions'].extend(self._build_session_api_data(session_))
        if self._occurrences:
            data['occurrences'] = fossilize(self._calculate_occurrences(event, self._fromDT, self._toDT,
                                            pytz.timezone(self._serverTZ)),
                                            {Period: IPeriodFossil}, tz=self._tz, naiveTZ=self._serverTZ)
        return data
Exemple #3
0
    def _build_event_api_data(self, event):
        can_manage = self.user is not None and event.can_manage(self.user)
        data = self._build_event_api_data_base(event)
        data.update({
            '_fossil':
            self.fossils_mapping['event'].get(self._detail_level),
            'categoryId':
            unicode(event.category_id),
            'category':
            event.category.getTitle(),
            'note':
            build_note_api_data(event.note),
            'roomFullname':
            event.room_name,
            'url':
            url_for('event.conferenceDisplay', confId=event.id,
                    _external=True),
            'modificationDate':
            self._serialize_date(event.as_legacy.getModificationDate()),
            'creationDate':
            self._serialize_date(event.as_legacy.getCreationDate()),
            'creator':
            self._serialize_person(event.creator,
                                   person_type='Avatar',
                                   can_manage=can_manage),
            'hasAnyProtection':
            event.as_legacy.hasAnyProtection(),
            'roomMapURL':
            event.room.map_url if event.room else None,
            'visibility':
            Conversion.visibility(event.as_legacy),
            'folders':
            build_folders_api_data(event),
            'chairs':
            self._serialize_persons(event.person_links,
                                    person_type='ConferenceChair',
                                    can_manage=can_manage),
            'material':
            build_material_legacy_api_data(event) +
            [build_note_legacy_api_data(event.note)]
        })
        if can_manage:
            data['allowed'] = self._serialize_access_list(event)
        if self._detail_level in {'contributions', 'subcontributions'}:
            data['contributions'] = []
            for contribution in event.contributions:
                include_subcontribs = self._detail_level == 'subcontributions'
                serialized_contrib = self._serialize_contribution(
                    contribution, include_subcontribs)
                data['contributions'].append(serialized_contrib)
        elif self._detail_level == 'sessions':
            # Contributions without a session
            data['contributions'] = []
            for contribution in event.contributions:
                if not contribution.session:
                    serialized_contrib = self._serialize_contribution(
                        contribution)
                    data['contributions'].append(serialized_contrib)

            data['sessions'] = []
            for session_ in event.sessions:
                data['sessions'].extend(self._build_session_api_data(session_))
        if self._occurrences:
            data['occurrences'] = fossilize(self._calculate_occurrences(
                event, self._fromDT, self._toDT,
                pytz.timezone(self._serverTZ)), {Period: IPeriodFossil},
                                            tz=self._tz,
                                            naiveTZ=self._serverTZ)
        return data
Exemple #4
0
class IConferenceMetadataFossil(_IncludeMaterialFossil, _IncludeACLFossil, IFossil):

    def getId(self):
        pass

    def getStartDate(self):
        pass
    getStartDate.convert = Conversion.datetime

    def getEndDate(self):
        pass
    getEndDate.convert = Conversion.datetime

    def getTitle(self):
        pass

    def getDescription(self):
        pass

    def getType(self):
        pass

    def getOwner(self):
        pass
    getOwner.convert = lambda x: x.getTitle()
    getOwner.name = 'category'

    def getCategoryId(self):
        pass
    getCategoryId.produce = lambda x: x.getOwner().getId()

    def getTimezone(self):
        pass

    def getNote(self):
        pass
    getNote.produce = lambda x: build_note_api_data(x.note)

    def getChairList(self):
        pass
    getChairList.name = 'chairs'
    getChairList.result = IConferenceChairMetadataFossil

    def getLocation(self):
        """ Location (CERN/...) """
    getLocation.convert = lambda l: l and l.getName()

    def getLocator(self):
        pass
    getLocator.convert = Conversion.url(urlHandlers.UHConferenceDisplay)
    getLocator.name = 'url'

    def getRoom(self):
        """ Room (inside location) """
    getRoom.convert = lambda r: r and r.getName()

    def getRoomFullName(self):
        """ Conference Room """
    getRoomFullName.produce = lambda c: c.getRoom()
    getRoomFullName.convert = Conversion.roomFullName
    getRoomFullName.name = 'roomFullname'

    def getVisibility(self):
        pass
    getVisibility.name = 'visibility'
    getVisibility.produce = lambda x: Conversion.visibility(x)

    def hasAnyProtection(self):
        pass

    def getAddress(self):
        pass

    def getCreator(self):
        pass
    getCreator.produce = lambda x: x.as_event.creator.as_avatar
    getCreator.result = IConferenceChairMetadataFossil

    def getCreationDate(self):
        pass

    def getModificationDate(self):
        pass

    def getRoomMapURL(self):
        pass
    getRoomMapURL.produce = lambda x: RoomLinker().getURL(x.getRoom(), x.getLocation())