Exemplo n.º 1
0
    def test_two_sites(self):
        site = SiteFactory.create(
            root_page=PageFactory.create(title='mypage', path='00010002'))

        site_b = SiteFactory.create(
            root_page=PageFactory.create(title='mypage', path='00010003'))

        SystemStringFactory.create(
            identifier='headline',
            string='headline a',
            site=site,
        )

        SystemStringFactory.create(
            identifier='headline',
            string='headline b',
            site=site_b,
        )

        fill_cache(site)
        fill_cache(site_b)

        preload(site)
        preload(site_b)

        set_site(site)
        self.assertEquals(gettext('headline'), 'headline a')

        set_site(site_b)
        self.assertEquals(gettext('headline'), 'headline b')
Exemplo n.º 2
0
    def process_request(self, request):
        site = request.site

        set_site(request.site)

        if not in_cache(site):
            fill_cache(site)

        preload(site)
Exemplo n.º 3
0
    def test_replace(self):
        site = SiteFactory.create(
            root_page=PageFactory.create(title='mypage', path='00010002'))

        SystemStringFactory.create(
            identifier='headline',
            string='Headline!',
            site=site,
        )

        set_site(site)
        fill_cache(site)
        preload(site)

        self.assertEquals(gettext('headline'), 'Headline!')
Exemplo n.º 4
0
    def test_empty_use_default(self):
        site = SiteFactory.create(
            root_page=PageFactory.create(title='mypage', path='00010002')
        )

        SystemStringFactory.create(
            identifier='title',
            string='',
            site=site,
            modified=False,
        )

        set_site(site)
        fill_cache(site)
        preload(site)

        self.assertEquals(systemtext('title', default='Default title'), 'Default title')
Exemplo n.º 5
0
    def process_request(self, request):
        if not hasattr(request, 'site'):
            logger.error('Request is missing site instance, have you added '
                         'wagtail.wagtailcore.middleware.SiteMiddleware '
                         'to your middleware classes?')

        site = request.site

        if not site:
            logger.error('Site is None on middleware request')
            return

        set_site(request.site)

        if not in_cache(site):
            fill_cache(site)

        preload(site)
Exemplo n.º 6
0
    def test_group_replace(self):
        site = SiteFactory.create(
            root_page=PageFactory.create(title='mypage', path='00010002')
        )

        SystemStringFactory.create(
            identifier='sub_headline',
            string='My subheadline',
            group='sub',
            site=site,
            modified=True,
        )

        set_site(site)
        fill_cache(site)
        preload(site)

        self.assertEquals(systemtext('sub_headline', 'sub'), 'My subheadline')
Exemplo n.º 7
0
    def test_empty_but_modified_setting_override(self):
        app_settings.SYSTEMTEXT_USE_DEFAULT_ON_EMPTY = True

        site = SiteFactory.create(
            root_page=PageFactory.create(title='mypage', path='00010002')
        )

        SystemStringFactory.create(
            identifier='title',
            string='',
            site=site,
            modified=True,
        )

        set_site(site)
        fill_cache(site)
        preload(site)

        self.assertEquals(systemtext('title', default='Default title'), 'Default title')
        self.assertEquals(systemtext('title'), '')
Exemplo n.º 8
0
    def setUp(self):
        site = SiteFactory.create(
            root_page=PageFactory.create(title='mypage', path='00010002')
        )

        SystemStringFactory.create(
            identifier='title',
            string='Headline!',
            site=site,
        )

        SystemStringFactory.create(
            identifier='subtitle',
            string='Sub Headline!',
            group='sub',
            site=site,
        )

        set_site(site)
        fill_cache(site)
        preload(site)