コード例 #1
0
ファイル: item.py プロジェクト: seantis/seantis.dir.events
    def show_source(self):
        if not IExternalEvent.providedBy(self.context):
            return False

        return getSecurityManager().checkPermission(
            permissions.ReviewPortalContent, self.context
        )
コード例 #2
0
ファイル: cleanup.py プロジェクト: seantis/seantis.dir.events
    def archive_past_events(self, directory, dryrun=False):

        catalog = IDirectoryCatalog(directory)
        query = catalog.catalog

        log.info("archiving past events (> 2 days old)")

        # events are in the past if they have been over for two days
        # (not one, to ensure that they are really over in all timezones)
        past = to_utc(datetime.utcnow() - timedelta(days=2))
        published_events = query(
            path={"query": directory.getPhysicalPath(), "depth": 2},
            object_provides=IEventsDirectoryItem.__identifier__,
            review_state=("published",),
            start={"query": past, "range": "max"},
            end={"query": past, "range": "max"},
        )

        past_events = []

        for event in published_events:
            event = event.getObject()

            assert event.start < past
            assert event.end < past

            # recurring events may be in the past with one of
            # their occurrences in the future
            if not has_future_occurrences(event, past):
                # published events may be imported events
                if not IExternalEvent.providedBy(event):
                    past_events.append(event)

        ids = [p.id for p in past_events]

        if past_events:
            log.info("archiving past events -> %s" % str(ids))

            if not dryrun:
                for event in past_events:
                    event.archive()
        else:
            log.info("no past events found")

        return ids
コード例 #3
0
ファイル: cleanup.py プロジェクト: shylux/seantis.dir.events
    def archive_past_events(self, directory, dryrun=False):

        catalog = IDirectoryCatalog(directory)
        query = catalog.catalog

        log.info('archiving past events (> 2 days old)')

        # events are in the past if they have been over for two days
        # (not one, to ensure that they are really over in all timezones)
        past = to_utc(datetime.utcnow() - timedelta(days=2))
        published_events = query(
            path={'query': directory.getPhysicalPath(), 'depth': 2},
            object_provides=IEventsDirectoryItem.__identifier__,
            review_state=('published', ),
            start={'query': past, 'range': 'max'},
            end={'query': past, 'range': 'max'}
        )

        past_events = []

        for event in published_events:
            event = event.getObject()

            assert event.start < past
            assert event.end < past

            # recurring events may be in the past with one of
            # their occurrences in the future
            if not has_future_occurrences(event, past):
                # published events may be imported events
                if not IExternalEvent.providedBy(event):
                    past_events.append(event)

        ids = [p.id for p in past_events]

        if past_events:
            log.info('archiving past events -> %s' % str(ids))

            if not dryrun:
                for event in past_events:
                    event.archive()
        else:
            log.info('no past events found')

        return ids
コード例 #4
0
ファイル: item.py プロジェクト: seantis/seantis.dir.events
 def allow_edit(self):
     return not IExternalEvent.providedBy(self)
コード例 #5
0
ファイル: item.py プロジェクト: shylux/seantis.dir.events
    def show_source(self):
        if not IExternalEvent.providedBy(self.context):
            return False

        return getSecurityManager().checkPermission(
            permissions.ReviewPortalContent, self.context)
コード例 #6
0
ファイル: item.py プロジェクト: shylux/seantis.dir.events
 def allow_edit(self):
     return not IExternalEvent.providedBy(self)