예제 #1
0
    def form_valid(self, form):
        hierarchy_id = self.kwargs.get('hierarchy_id')
        original = get_object_or_404(Hierarchy, id=hierarchy_id)

        name = form.cleaned_data['name']
        base_url = form.cleaned_data['base_url']

        clone = Hierarchy.clone(original, name, base_url)

        self.success_url = clone.get_root().get_edit_url()
        return super(CloneHierarchyView, self).form_valid(form)
예제 #2
0
    def form_valid(self, form):
        hierarchy_id = self.kwargs.get('hierarchy_id')
        original = get_object_or_404(Hierarchy, id=hierarchy_id)

        name = form.cleaned_data['name']
        base_url = form.cleaned_data['base_url']

        clone = Hierarchy.clone(original, name, base_url)

        self.success_url = clone.get_root().get_edit_url()
        return super(CloneHierarchyView, self).form_valid(form)
예제 #3
0
    def test_clone_hierarchy(self):
        self.section1.add_pageblock_from_dict({
            'block_type': 'Test Block',
            'body': 'test body',
        })
        duplicate = Hierarchy.clone(self.h, 'foo', '/foo/')

        descendants = duplicate.get_root().get_descendants()
        self.assertTrue(descendants[0].label, 'Section 1')
        self.assertTrue(descendants[0].depth, 1)
        self.assertEquals(descendants[0].pageblock_set.count(), 1)

        self.assertTrue(descendants[1].label, 'Section 2')
        self.assertTrue(descendants[1].depth, 1)

        self.assertTrue(descendants[2].label, 'Section 3')
        self.assertTrue(descendants[2].depth, 1)

        self.assertTrue(descendants[3].label, 'Section 4')
        self.assertTrue(descendants[3].depth, 2)

        self.assertTrue(descendants[4].label, 'Section 5')
        self.assertTrue(descendants[4].depth, 3)
예제 #4
0
    def test_clone_hierarchy(self):
        self.section1.add_pageblock_from_dict({
            'block_type': 'Test Block',
            'body': 'test body',
        })
        duplicate = Hierarchy.clone(self.h, 'foo', '/foo/')

        descendants = duplicate.get_root().get_descendants()
        self.assertTrue(descendants[0].label, 'Section 1')
        self.assertTrue(descendants[0].depth, 1)
        self.assertEquals(descendants[0].pageblock_set.count(), 1)

        self.assertTrue(descendants[1].label, 'Section 2')
        self.assertTrue(descendants[1].depth, 1)

        self.assertTrue(descendants[2].label, 'Section 3')
        self.assertTrue(descendants[2].depth, 1)

        self.assertTrue(descendants[3].label, 'Section 4')
        self.assertTrue(descendants[3].depth, 2)

        self.assertTrue(descendants[4].label, 'Section 5')
        self.assertTrue(descendants[4].depth, 3)