コード例 #1
0
def create_page(**kwargs):
    """
    Creates Page object with given kwargs.
    """
    default_user = User.objects.get(
        username=TEST_USERS["superuser"]["username"]
    )
    default_template = Template.objects.all()[0]
    default_style = Style.objects.all()[0]
    default_markup = 0 # html without TinyMCE

    page = Page(
        name             = kwargs.get("name", "New Page"),
        shortcut         = kwargs.get("shortcut", None),
        content          = kwargs.get("content", "TestPageContent"),
        template         = kwargs.get("template", default_template),
        style            = kwargs.get("style", default_style),
        markup           = kwargs.get("markup", default_markup),
        createby         = kwargs.get("user", default_user),
        lastupdateby     = kwargs.get("user", default_user),
        showlinks        = kwargs.get("showlinks", True),
        permitViewPublic = kwargs.get("permitViewPublic", True),
        permitViewGroup  = kwargs.get("permitViewGroup", None),
        permitEditGroup  = kwargs.get("permitEditGroup", None),
        parent           = kwargs.get("parent", None),
        )
    page.save()
    return page
コード例 #2
0
ファイル: PyRM_PyLucid_setup.py プロジェクト: aeoncipher/pyrm
 def create_page(self, data):    
     page_data = self.defaults.copy()
     page_data.update(data)
     pprint(page_data)
     p = Page(**page_data)
     p.save()
     return p
コード例 #3
0
    def test_page(self):
        """
        Create a page with a minimum of args.
        If name and shortcut is None, it should be worked, too.
        """
        default_user = User.objects.get(
            username=tests.TEST_USERS["superuser"]["username"]
        )

        default_template = Template.objects.all()[0]
        default_style = Style.objects.all()[0]
        default_markup = 0 # html without TinyMCE

        p = Page(
            name = None,
            shortcut = None,

            template = default_template,
            style = default_style,
            markup = default_markup,
            createby = default_user,
            lastupdateby = default_user,
        )
        p.save()

        self.failUnlessEqual(p.name, "")
        self.failUnlessEqual(p.shortcut, "1")
コード例 #4
0
            print page_dict

            parent_id = page_dict.pop("parent")

            old_template_id = page_dict["template"]
            page_dict["template"] = template_map[old_template_id]

            old_style_id = page_dict["style"]
            page_dict["style"] = style_map[old_style_id]

            for key in ("title", "keywords", "description"):
                if page_dict[key] == None:
                    page_dict[key] = ""

            new_page = Page(**page_dict)
            new_page.save()
            page_map[id] = new_page

            parent_data.append(
                (id, parent_id)
            )

        print
        print "_"*80
        # Only now we can rebuild the nested sets hierarchy
        print "rebuild the nested sets hierarchy\n"
        for page_id, parent_id in parent_data:
            if parent_id == 0:
                # there is no parent page
                parent_page = None