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
0012481a
Commit
0012481a
authored
Aug 22, 2012
by
benjaoming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:benjaoming/django-wiki
parents
c0d7e2ab
63003aa6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
5 deletions
+33
-5
wiki/models/urlpath.py
+23
-1
wiki/templates/wiki/error.html
+1
-1
wiki/views/article.py
+9
-3
No files found.
wiki/models/urlpath.py
View file @
0012481a
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
logging
from
django.contrib.contenttypes
import
generic
from
django.contrib.contenttypes
import
generic
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.sites.models
import
Site
from
django.contrib.sites.models
import
Site
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.db
import
models
from
django.db
import
models
,
transaction
from
django.db.models.signals
import
pre_delete
,
post_save
from
django.db.models.signals
import
pre_delete
,
post_save
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext
...
@@ -16,6 +18,8 @@ from wiki.conf import settings
...
@@ -16,6 +18,8 @@ from wiki.conf import settings
from
wiki.core.exceptions
import
NoRootURL
,
MultipleRootURLs
from
wiki.core.exceptions
import
NoRootURL
,
MultipleRootURLs
from
wiki.models.article
import
ArticleRevision
,
ArticleForObject
,
Article
from
wiki.models.article
import
ArticleRevision
,
ArticleForObject
,
Article
log
=
logging
.
getLogger
(
__name__
)
class
URLPath
(
MPTTModel
):
class
URLPath
(
MPTTModel
):
"""
"""
Strategy: Very few fields go here, as most has to be managed through an
Strategy: Very few fields go here, as most has to be managed through an
...
@@ -89,6 +93,24 @@ class URLPath(MPTTModel):
...
@@ -89,6 +93,24 @@ class URLPath(MPTTModel):
return
ancestor
return
ancestor
return
None
return
None
@transaction.commit_manually
def
delete_subtree
(
self
):
"""
NB! This deletes this urlpath, its children, and ALL of the related
articles. This is a purged delete and CANNOT be undone.
"""
try
:
for
descendant
in
self
.
get_descendants
(
include_self
=
True
)
.
order_by
(
"-level"
):
print
"deleting "
,
descendant
descendant
.
article
.
delete
()
transaction
.
commit
()
except
:
transaction
.
rollback
()
log
.
exception
(
"Exception deleting article subtree."
)
@classmethod
@classmethod
def
root
(
cls
):
def
root
(
cls
):
site
=
Site
.
objects
.
get_current
()
site
=
Site
.
objects
.
get_current
()
...
...
wiki/templates/wiki/error.html
View file @
0012481a
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
{% if error_type == "ancestors_missing" %}
{% if error_type == "ancestors_missing" %}
<div
class=
"missing"
>
<div
class=
"missing"
>
<p>
This article was not found, and neither was its parent article.
<a
href=
"{% url 'wiki:get' path='' %}"
>
Go
back
to the main wiki article
</a></p>
<p>
This article was not found, and neither was its parent article.
<a
href=
"{% url 'wiki:get' path='' %}"
>
Go to the main wiki article
</a></p>
</div>
</div>
{% else %}
{% else %}
...
...
wiki/views/article.py
View file @
0012481a
...
@@ -176,8 +176,7 @@ class Delete(FormView, ArticleMixin):
...
@@ -176,8 +176,7 @@ class Delete(FormView, ArticleMixin):
if
can_moderate
and
purge
:
if
can_moderate
and
purge
:
# First, remove children
# First, remove children
if
self
.
urlpath
:
if
self
.
urlpath
:
for
descendant
in
self
.
urlpath
.
get_descendants
(
include_self
=
True
):
self
.
urlpath
.
delete_subtree
()
descendant
.
article
.
delete
()
else
:
else
:
self
.
article
.
delete
()
self
.
article
.
delete
()
...
@@ -509,6 +508,7 @@ class Settings(ArticleMixin, TemplateView):
...
@@ -509,6 +508,7 @@ class Settings(ArticleMixin, TemplateView):
# could be mixed up with a different instance
# could be mixed up with a different instance
# Use strategy from Edit view...
# Use strategy from Edit view...
setattr
(
settings_forms
[
i
],
'action'
,
'form
%
d'
%
i
)
setattr
(
settings_forms
[
i
],
'action'
,
'form
%
d'
%
i
)
return
settings_forms
return
settings_forms
def
post
(
self
,
*
args
,
**
kwargs
):
def
post
(
self
,
*
args
,
**
kwargs
):
...
@@ -531,8 +531,14 @@ class Settings(ArticleMixin, TemplateView):
...
@@ -531,8 +531,14 @@ class Settings(ArticleMixin, TemplateView):
def
get
(
self
,
*
args
,
**
kwargs
):
def
get
(
self
,
*
args
,
**
kwargs
):
self
.
forms
=
[]
self
.
forms
=
[]
# There is a bug where articles fetched with select_related have bad boolean field https://code.djangoproject.com/ticket/15040
# We fetch a fresh new article for this reason
new_article
=
models
.
Article
.
objects
.
get
(
id
=
self
.
article
.
id
)
for
Form
in
self
.
get_form_classes
():
for
Form
in
self
.
get_form_classes
():
self
.
forms
.
append
(
Form
(
self
.
article
,
self
.
request
))
self
.
forms
.
append
(
Form
(
new_article
,
self
.
request
))
return
super
(
Settings
,
self
)
.
get
(
*
args
,
**
kwargs
)
return
super
(
Settings
,
self
)
.
get
(
*
args
,
**
kwargs
)
def
get_success_url
(
self
):
def
get_success_url
(
self
):
...
...
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