How to use the feincms3.apps.apps_urlconf function in feincms3

To help you get started, we’ve selected a few feincms3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
def test_apps_urlconf_no_apps(self):
        self.assertEqual(apps_urlconf(apps=[]), "testapp.urls")
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
language_code="de",
            is_active=True,
            application="translated-articles",
        )

        original = TranslatedArticle.objects.create(title="News", language_code="en")
        translated = TranslatedArticle.objects.create(
            title="Neues", language_code="de", translation_of=original
        )

        self.assertEqual(
            [language["object"] for language in translations(original.translations())],
            [original, translated, None],
        )

        with override_urlconf(apps_urlconf()):
            self.assertEqual(
                original.get_absolute_url(), "/home-en/{}/".format(original.pk)
            )
            self.assertEqual(
                translated.get_absolute_url(), "/home-de/{}/".format(translated.pk)
            )
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
self.assertEqual(
                    reverse_app(
                        (article.category, "articles"),
                        "article-detail",
                        kwargs={"pk": article.pk},
                        languages=["de", "en"],
                    ),
                    "/de/publications/%s/" % article.pk,
                )

        response = self.client.get("/de/publications/%s/" % article.pk)
        self.assertContains(response, "<h1>publications 0</h1>", 1)

        # The exact value of course does not matter, just the fact that the
        # value does not change all the time.
        self.assertEqual(apps_urlconf(), "urlconf_fe9552a8363ece1f7fcf4970bf575a47")
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
),
            (
                "{% reverse_app namespaces 'article-detail' pk=42 fallback='/a/' as a %}{{ a }}",  # noqa
                "/blog/42/",
                {"namespaces": ["stuff", "blog"]},
            ),
            ("{% reverse_app 'bla' 'bla' fallback='/test/' %}", "/test/", {}),
            (
                "{% reverse_app 'bla' 'bla' fallback='/test/' as t %}{{ t }}",
                "/test/",
                {},
            ),
            ("{% reverse_app 'bla' 'bla' as t %}{{ t|default:'blub' }}", "blub", {}),
        ]

        with override_urlconf(apps_urlconf()):
            for tpl, out, ctx in tests:
                t = Template("{% load feincms3 %}" + tpl)
                self.assertEqual(t.render(Context(ctx)).strip(), out)

            self.assertRaises(
                NoReverseMatch,
                Template("{% load feincms3 %}{% reverse_app 'a' 'a' %}").render,
                Context(),
            )
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
'class="article"',
            2,  # Last page with instances (2nd)
        )
        self.assertContains(
            self.client.get("/de/blog/?page=invalid"),
            'class="article"',
            5,  # First page
        )

        response = self.client.get("/de/blog/")
        self.assertContains(response, 'class="article"', 5)

        response = self.client.get("/en/publications/")
        self.assertContains(response, 'class="article"', 5)

        with override_urlconf(apps_urlconf()):
            article = Article.objects.order_by("pk").first()
            with override("de"):
                self.assertEqual(
                    article.get_absolute_url(), "/de/publications/%s/" % article.pk
                )

            with override("en"):
                self.assertEqual(
                    article.get_absolute_url(), "/en/publications/%s/" % article.pk
                )

                # The german URL is returned when specifying the ``languages``
                # list explicitly.
                self.assertEqual(
                    reverse_app(
                        (article.category, "articles"),