@@ 199,14 199,15 @@ class URLPath(MPTTModel):
return reverse('wiki:get', kwargs={'path': self.path})
@classmethod
- def create_root(cls, site=None, title="Root", **kwargs):
+ def create_root(cls, site=None, title="Root", request=None, **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??)
article = Article()
- article.add_revision(ArticleRevision(title=title, **kwargs),
- save=True)
+ revision = ArticleRevision(title=title, **kwargs)
+ if request: revision.set_from_request(request)
+ article.add_revision(revision, save=True)
article.save()
root = cls.objects.create(site=site, article=article)
article.add_object_relation(root)
@@ 218,7 219,8 @@ class URLPath(MPTTModel):
def create_article(cls, parent, slug, site=None, title="Root", article_kwargs={}, **kwargs):
"""Utility function:
Create a new urlpath with an article and a new revision for the article"""
- if not site: site = Site.objects.get_current()
+ if not site:
+ site = Site.objects.get_current()
article = Article(**article_kwargs)
article.add_revision(ArticleRevision(title=title, **kwargs),
save=True)
@@ 718,7 718,8 @@ def root_create(request):
create_form = forms.CreateRootForm(request.POST)
if create_form.is_valid():
models.URLPath.create_root(title=create_form.cleaned_data["title"],
- content=create_form.cleaned_data["content"])
+ content=create_form.cleaned_data["content"],
+ request=request)
return redirect("wiki:root")
else:
create_form = forms.CreateRootForm()