예제 #1
0
파일: tests.py 프로젝트: Trion/chunkycms
    def test_page_model(self):
        """
        Tests Page Model
        """

        # Test page creation
        page = Page.objects.get(slug="test")
        self.assertEqual(page.title, "Test")

        # Test automatic slug generation
        page = Page()
        page.title = "Test"
        page.content = "Yet another Test"
        page.author = self.author
        page.save()
        page = Page.objects.get(slug="test1")
        self.assertEqual(page.content, "Yet another Test")

        # Test get by path
        page = Page.get_by_path("test/foo")
        self.assertEqual(page.title, "Foo")

        # Test direct SelfParent Exception
        with self.assertRaises(SelfParent):
            page = Page.objects.get(slug="test")
            page.parent = page
            page.save()

        # Test chained SelfParent Exception
        with self.assertRaises(SelfParent):
            page = Page.objects.get(slug="test")
            page.parent = Page.get_by_path("test/foo")
            page.save()
예제 #2
0
파일: views.py 프로젝트: Trion/chunkycms
def show_page(request, path):
    """ shows a page """

    try:
        page = Page.get_by_path(path)
    except Page.DoesNotExist:
        raise Http404

    return render_to_response("chunkycms/page.html", context_instance=RequestContext(request, {'page': page}))