コード例 #1
0
ファイル: urlpath.py プロジェクト: MechanisM/django-wiki
 def create_article(cls, parent, slug, site=None, title="Root", **kwargs):
     if not site:
         site = Site.objects.get_current()
     newpath = cls.objects.create(site=site, parent=parent, slug=slug)
     article = Article(title=title)
     article.add_revision(ArticleRevision(title=title, **kwargs), save=True)
     article.add_object_relation(newpath)
     return newpath
コード例 #2
0
ファイル: urlpath.py プロジェクト: MechanisM/django-wiki
 def create_root(cls, site=None, title="Root", **kwargs):
     if not site:
         site = Site.objects.get_current()
     root_nodes = cls.objects.root_nodes().filter(site=site)
     if not root_nodes:
         # (get_or_create does not work for MPTT models??)
         root = cls.objects.create(site=site)
         article = Article(title=title)
         article.add_revision(ArticleRevision(title=title, **kwargs), save=True)
         article.add_object_relation(root)
     else:
         root = root_nodes[0]
     return root