예제 #1
0
    def test_find_site(self):
        self.assertEqual(
            find_site(self.portal.newsite.subfolder),
            self.portal.newsite
        )

        self.assertEqual(
            find_site(self.portal.newsite.subfolder, as_url=True),
            'http://nohost/plone/newsite'
        )
예제 #2
0
    def update(self):
        context = aq_inner(self.context)

        sb = self.data.search_base
        site_url = find_site(context, as_url=True)
        self.calendar_url = '%s%s' % (site_url, sb and sb or '/event_listing')

        self.year, self.month = year, month = self.year_month_display()
        self.prev_year, self.prev_month = prev_year, prev_month = (
            self.get_previous_month(year, month))
        self.next_year, self.next_month = next_year, next_month = (
            self.get_next_month(year, month))
        # TODO: respect current url-query string
        self.prev_query = '?month=%s&year=%s' % (prev_month, prev_year)
        self.next_query = '?month=%s&year=%s' % (next_month, next_year)

        self.cal = calendar.Calendar(first_weekday())
        self._ts = getToolByName(context, 'translation_service')
        self.month_name = PLMF(self._ts.month_msgid(month),
                              default=self._ts.month_english(month))

        # strftime %w interprets 0 as Sunday unlike the calendar.
        strftime_wkdays = [wkday_to_mon1(day)
                for day in self.cal.iterweekdays()]
        self.weekdays = [
            PLMF(self._ts.day_msgid(day, format='s'),
                 default=self._ts.weekday_english(day, format='a'))
            for day in strftime_wkdays
        ]
예제 #3
0
    def update(self):
        context = aq_inner(self.context)

        sb = self.data.search_base
        site_url = find_site(context, as_url=True)
        self.calendar_url = '%s%s' % (site_url, sb and sb or '/event_listing')

        self.year, self.month = year, month = self.year_month_display()
        self.prev_year, self.prev_month = prev_year, prev_month = (
            self.get_previous_month(year, month))
        self.next_year, self.next_month = next_year, next_month = (
            self.get_next_month(year, month))
        # TODO: respect current url-query string
        self.prev_query = '?month=%s&year=%s' % (prev_month, prev_year)
        self.next_query = '?month=%s&year=%s' % (next_month, next_year)

        self.cal = calendar.Calendar(first_weekday())
        self._ts = getToolByName(context, 'translation_service')
        self.month_name = PLMF(self._ts.month_msgid(month),
                               default=self._ts.month_english(month))

        # strftime %w interprets 0 as Sunday unlike the calendar.
        strftime_wkdays = [
            wkday_to_mon1(day) for day in self.cal.iterweekdays()
        ]
        self.weekdays = [
            PLMF(self._ts.day_msgid(day, format='s'),
                 default=self._ts.weekday_english(day, format='a'))
            for day in strftime_wkdays
        ]
예제 #4
0
    def __init__(self, *args):
        base.Renderer.__init__(self, *args)

        context = aq_inner(self.context)

        sb = self.data.search_base
        site_url = find_site(context, as_url=True)
        calendar_url = '%s%s' % (site_url, sb and sb or '/event_listing')
        self.next_url = '%s?mode=future' % calendar_url
        self.prev_url = '%s?mode=past' % calendar_url

        portal_state = getMultiAdapter((self.context, self.request), name='plone_portal_state')
        self.portal = portal_state.portal()
예제 #5
0
    def search_base_context(self):
        search_base_path = uuidToObject(self.data.search_base_uid)
        if search_base_path is not None:
            search_base_path = '/'.join(search_base_path.getPhysicalPath())

        if search_base_path:
            portal = find_ploneroot(self.context)
            search_base = '/'.join(search_base_path.split('/')[2:])
            return portal.unrestrictedTraverse(
                search_base.lstrip('/')
            )

        return find_site(self.context, as_url=False)
예제 #6
0
    def __init__(self, *args):
        base.Renderer.__init__(self, *args)

        context = aq_inner(self.context)

        sb = self.data.search_base
        site_url = find_site(context, as_url=True)
        calendar_url = '%s%s' % (site_url, sb and sb or '/event_listing')
        self.next_url = '%s?mode=future' % calendar_url
        self.prev_url = '%s?mode=past' % calendar_url

        portal_state = getMultiAdapter((self.context, self.request),
                                       name='plone_portal_state')
        self.portal = portal_state.portal()
예제 #7
0
def get_calendar_url(context, search_base):
    # search_base is always from the portal_root object. We won't include
    # the path from the portal root object, so we traverse to the calendar
    # object and call it's url then.
    calendar_url = None
    if search_base:
        portal = find_ploneroot(context)
        calendar_url = portal.unrestrictedTraverse(
            search_base.lstrip('/')  # start relative, first slash is omitted
        ).absolute_url()
    else:
        site_url = find_site(context, as_url=True)
        calendar_url = '%s/event_listing' % site_url

    return calendar_url
예제 #8
0
    def __init__(self, *args):
        base.Renderer.__init__(self, *args)

        context = aq_inner(self.context)

        sb = self.data.search_base
        site_url = find_site(context, as_url=True)
        calendar_url = "%s%s" % (site_url, sb and sb or "/event_listing")
        self.next_url = "%s?mode=future" % calendar_url
        self.prev_url = "%s?mode=past" % calendar_url

        # BBB TODO: remove with 1.0
        self.prev_events_link = self.prev_url
        self.all_events_link = self.next_url

        portal_state = getMultiAdapter((self.context, self.request), name="plone_portal_state")
        self.portal = portal_state.portal()