Пример #1
0
    def update(self, **kwargs):
        # Update date range
        daterange = self.request.get('range', self.get_last_daterange())
        if not dates.is_valid_daterange(daterange):
            daterange = 'this_month'
        else:
            self.set_last_daterange(daterange)

        # Update custom dates
        start = self.get_last_custom_start_date()
        end = self.get_last_custom_end_date()
        if daterange == 'custom':
            tz = start.tzinfo
            try:
                start = parse(self.request.get('from'), ignoretz=True)
                start = start.replace(tzinfo=tz)
                end = parse(self.request.get('to'), ignoretz=True)
                end = end.replace(tzinfo=tz)
                end = max(start, end)
                self.set_last_custom_dates(start, end)
            except:
                pass

        # Update state
        state = self.request.get('state', self.get_last_state())
        if not self.show_state_filters or state not in (
            'submitted', 'published', 'archived', 'hidden'
        ):
            state = 'published'
        else:
            self.set_last_state(state)

        # Update import source
        source = self.request.get('source', self.get_last_import_source())
        if not self.show_import_sources:
            source = ''
        else:
            self.set_last_import_source(source)

        self.catalog.state = state
        self.catalog.daterange = daterange
        self.catalog.import_source = source
        self.catalog.set_custom_dates(start, end)

        if not self.is_ical_export and not self.is_json_export:
            super(EventsDirectoryView, self).update(**kwargs)

        if not self.fired_event:
            notify(ResourceViewedEvent(self.context))
            self.fired_event = True
Пример #2
0
    def update(self, **kwargs):
        daterange = self.request.get('range', self.get_last_daterange())

        # do not trust the user's input blindly
        if not dates.is_valid_daterange(daterange):
            daterange = 'this_month'
        else:
            self.set_last_daterange(daterange)

        state = self.request.get('state', self.get_last_state())

        if not self.show_state_filters or state not in (
            'submitted', 'published', 'archived'
        ):
            state = 'published'
        else:
            self.set_last_state(state)

        self.catalog.state = state
        self.catalog.daterange = daterange

        if not self.is_ical_export:
            super(EventsDirectoryView, self).update(**kwargs)
Пример #3
0
 def set_daterange(self, range):
     assert dates.is_valid_daterange(range), "invalid date range %s" % range
     self._daterange = range
Пример #4
0
 def set_daterange(self, range):
     assert dates.is_valid_daterange(range), "invalid date range %s" % range
     self._daterange = range