Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-wiki
Commits
2ed231a7
Commit
2ed231a7
authored
Feb 03, 2013
by
benjaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply user info on the creater of the first revision of the root article
parent
c50e05f6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
wiki/models/urlpath.py
+6
-4
wiki/views/article.py
+2
-1
No files found.
wiki/models/urlpath.py
View file @
2ed231a7
...
...
@@ -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
)
...
...
wiki/views/article.py
View file @
2ed231a7
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment