How to use the feincms3.apps.reverse 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_move_to_root_first(self):
        root, p1, p2 = self.prepare_for_move()
        client = self.login()

        client.post(
            reverse("admin:testapp_page_move", args=(p2.pk,)),
            {"move_to": "first", "of": ""},
        )

        self.assertEqual(
            [(p.pk, p.parent_id, p.position) for p in Page.objects.all()],
            [(p2.pk, None, 10), (root.pk, None, 20), (p1.pk, root.pk, 10)],
        )
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
clone_url = reverse("admin:testapp_page_clone", args=(blog.pk,))

        response = client.get(clone_url)
        self.assertContains(response, "_set_content")
        self.assertContains(response, "set_application")

        response = client.post(clone_url, {"target": home.pk, "set_application": True})
        self.assertContains(response, "Apps may not have any descendants in the tree.")

        # The other way round works
        clone_url = reverse("admin:testapp_page_clone", args=(home.pk,))

        response = client.post(clone_url, {"target": blog.pk, "set_application": True})
        self.assertRedirects(
            response, reverse("admin:testapp_page_change", args=(blog.pk,))
        )

        # No apps in tree anymore
        self.assertEqual(Page.objects.exclude(application="").count(), 0)
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
def test_invalid_parent(self):
        root, p1, p2 = self.prepare_for_move()
        p1.application = "blog"
        p1.save()

        p2 = Page.objects.get(pk=p2.pk)
        p2.parent_id = p1.pk

        # Apps may not have descendants
        self.assertRaises(ValidationError, p2.full_clean)

        client = self.login()
        response = client.post(
            reverse("admin:testapp_page_move", args=(p2.pk,)),
            {"move_to": "first", "of": p1.pk},
        )

        self.assertContains(
            response,
            "<li>Invalid parent: Apps may not have any descendants.</li>",
            status_code=200,
        )
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
def test_invalid_move(self):
        root, p1, p2 = self.prepare_for_move()
        client = self.login()

        response = client.post(reverse("admin:testapp_page_move", args=(root.pk,)), {})
        self.assertContains(response, "This field is required.", 1)

        response = client.post(
            reverse("admin:testapp_page_move", args=(root.pk,)),
            {"move_to": "first", "of": p1.pk},
        )
        self.assertContains(
            response,
            "Select a valid choice. That choice is not one of the available choices.",  # noqa
        )

        response = client.post(
            reverse("admin:testapp_page_move", args=(root.pk,)),
            {"move_to": "first", "of": root.pk},
        )
        self.assertContains(
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
is_active=True,
            menu="main",
        )

        home_de.testapp_snippet_set.create(
            template_name="snippet-33.html", ordering=10, region="main"
        )

        client = self.login()
        response = client.post(
            reverse("admin:testapp_page_clone", args=(home_en.pk,)),
            {"target": home_de.pk, "_set_content": True},
        )
        # print(response.content.decode("utf-8"))
        self.assertRedirects(
            response, reverse("admin:testapp_page_change", args=(home_de.pk,))
        )

        self.assertEqual(
            list(home_de.testapp_snippet_set.values_list("template_name", flat=True)),
            ["snippet.html"],
        )
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
def test_apps_cloning_validation(self):
        """Checks that the target is properly validated when cloning"""
        home, blog = self._apps_validation_models()
        client = self.login()

        clone_url = reverse("admin:testapp_page_clone", args=(blog.pk,))

        response = client.get(clone_url)
        self.assertContains(response, "_set_content")
        self.assertContains(response, "set_application")

        response = client.post(clone_url, {"target": home.pk, "set_application": True})
        self.assertContains(response, "Apps may not have any descendants in the tree.")

        # The other way round works
        clone_url = reverse("admin:testapp_page_clone", args=(home.pk,))

        response = client.post(clone_url, {"target": blog.pk, "set_application": True})
        self.assertRedirects(
            response, reverse("admin:testapp_page_change", args=(blog.pk,))
        )
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
def test_apps_cloning_validation(self):
        """Checks that the target is properly validated when cloning"""
        home, blog = self._apps_validation_models()
        client = self.login()

        clone_url = reverse("admin:testapp_page_clone", args=(blog.pk,))

        response = client.get(clone_url)
        self.assertContains(response, "_set_content")
        self.assertContains(response, "set_application")

        response = client.post(clone_url, {"target": home.pk, "set_application": True})
        self.assertContains(response, "Apps may not have any descendants in the tree.")

        # The other way round works
        clone_url = reverse("admin:testapp_page_clone", args=(home.pk,))

        response = client.post(clone_url, {"target": blog.pk, "set_application": True})
        self.assertRedirects(
            response, reverse("admin:testapp_page_change", args=(blog.pk,))
        )

        # No apps in tree anymore
        self.assertEqual(Page.objects.exclude(application="").count(), 0)
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
def test_move_to_child(self):
        root, p1, p2 = self.prepare_for_move()
        client = self.login()

        client.post(
            reverse("admin:testapp_page_move", args=(p2.pk,)),
            {"move_to": "first", "of": p1.pk},
        )

        self.assertEqual(
            [(p.pk, p.parent_id, p.position) for p in Page.objects.all()],
            [(root.pk, None, 10), (p1.pk, root.pk, 10), (p2.pk, p1.pk, 10)],
        )