コード例 #1
0
 def setup(self):
     # use a context manager to ensure these settings are
     # only used here
     with override_settings(WAGTAILTRANS_SYNC_TREE=True, WAGTAILTRANS_LANGUAGES_PER_SITE=True):
         register_site_languages()(SiteLanguages)
         self.site = sites.SiteFactory()
         SiteLanguages.for_site(self.site)
         self.default_language = Language.objects.get(code='en')
         self.site.sitelanguages.default_language = self.default_language
コード例 #2
0
ファイル: test_signals.py プロジェクト: yvess/wagtailtrans
    def test_site_languages(self):
        site = sites.SiteFactory()
        SiteLanguages.for_site(site)  # Initialize sitelanguages

        default_language = Language.objects.default()
        lang = language.LanguageFactory(code='nl', is_default=False)
        site.sitelanguages.default_language = lang
        site.sitelanguages.save()

        pages = sites.create_site_tree(language=default_language, site=site)
        homepage = HomePageFactory.build(language=default_language)
        pages[0].add_child(instance=homepage)

        signals.force_parent_language(page=homepage, parent=site.root_page)

        assert homepage.language == lang