예제 #1
0
    def test_page_content_is_also_duplicated(self):
        u = User.objects.create(
            username='******', password='', email='*****@*****.**')
        u.is_staff = True
        u.set_password('secret')
        u.save()

        login = self.client.login(username='******', password='******')
        self.assertTrue(login)

        p = Page.objects.get(slug='page-1')
        p2 = Page.objects.get(slug='page-2')
        p2_content = BasicPage.objects.create(
            page=p2, content="This is some content for the page")
        p2_content.save()

        data = {
            'node': 2,              # Select Node id 2 ...
            'position': 'right',     # ... duplicate to the right of ...
            'target': 2,            # ... node id 2 (myself)
        }
        form = DuplicatePageForm(data)
        if form.is_valid():
            form.save()

        p3 = Page.objects.get(slug='page-2-copy')
        self.assertEqual(
            'This is some content for the page', p3.contents.content)
예제 #2
0
    def test_page_content_is_also_duplicated(self):
        u = User.objects.create(username='******',
                                password='',
                                email='*****@*****.**')
        u.is_staff = True
        u.set_password('secret')
        u.save()

        login = self.client.login(username='******', password='******')
        self.assertTrue(login)

        p = Page.objects.get(slug='page-1')
        p2 = Page.objects.get(slug='page-2')
        p2_content = BasicPage.objects.create(
            page=p2, content="This is some content for the page")
        p2_content.save()

        data = {
            'node': 2,  # Select Node id 2 ...
            'position': 'right',  # ... duplicate to the right of ...
            'target': 2,  # ... node id 2 (myself)
        }
        form = DuplicatePageForm(data)
        if form.is_valid():
            form.save()

        p3 = Page.objects.get(slug='page-2-copy')
        self.assertEqual('This is some content for the page',
                         p3.contents.content)
예제 #3
0
 def post(self, *args, **kwargs):
     form = DuplicatePageForm(self.request.POST)
     if form.is_valid():
         new_page = form.save()
         next = reverse('admin:ostinato_pages_page_change',
                        args=(new_page.id,))
     else:
         next = reverse('admin:ostinato_pages_page_changelist')
     return http.HttpResponseRedirect(next)
예제 #4
0
 def post(self, *args, **kwargs):
     form = DuplicatePageForm(self.request.POST)
     if form.is_valid():
         form.save()
     return http.HttpResponseRedirect(reverse('admin:pages_page_changelist'))