Пример #1
0
    def show_source(self):
        if not IExternalEvent.providedBy(self.context):
            return False

        return getSecurityManager().checkPermission(
            permissions.ReviewPortalContent, self.context
        )
Пример #2
0
    def allow_action(self, action, item_brain):
        """ Return true if the given action is allowed. This is not a
        wrapper for the transition guards of the event workflow. Instead
        it is called *by* the transition guards.

        This allows a number of people to work together on an event website
        with every person having its own group of events which he or she is
        responsible for.

        Per default, only external events may be hidden and only internal
        events archived.

        A client specific packages like izug.seantis.dir.events may
        use a custom adapter to override the default behaviour.
        """
        result = True

        try:
            IExternalEvent(item_brain)
            external_event = True
        except:
            external_event = False

        if external_event:
            if action not in ['hide', 'publish']:
                result = False
        else:
            if action == 'hide':
                result = False

        guard = queryAdapter(self, IActionGuard)
        if guard:
            result = guard.allow_action(action, item_brain)
        return result
Пример #3
0
    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
    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
Пример #5
0
 def allow_edit(self):
     return not IExternalEvent.providedBy(self)
Пример #6
0
 def import_source(self):
     try:
         result = IExternalEvent(self.context).source
     except:
         result = ""
     return result
Пример #7
0
    def show_source(self):
        if not IExternalEvent.providedBy(self.context):
            return False

        return getSecurityManager().checkPermission(
            permissions.ReviewPortalContent, self.context)
Пример #8
0
 def allow_edit(self):
     return not IExternalEvent.providedBy(self)