Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
a2841af8
Commit
a2841af8
authored
Aug 14, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added views for automatic course article creation.
parent
c8fc7bed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
2 deletions
+99
-2
lms/djangoapps/course_wiki/__init__.py
+0
-0
lms/djangoapps/course_wiki/views.py
+92
-0
lms/envs/common.py
+1
-0
lms/urls.py
+6
-2
No files found.
lms/djangoapps/course_wiki/__init__.py
0 → 100644
View file @
a2841af8
lms/djangoapps/course_wiki/views.py
0 → 100644
View file @
a2841af8
from
django.shortcuts
import
redirect
from
wiki.core.exceptions
import
NoRootURL
from
wiki.models
import
URLPath
,
Article
from
courseware.courses
import
check_course
def
root_create
(
request
):
"""
In the edX wiki, we don't show the root_create view. Instead, we
just create the root automatically if it doesn't exist.
"""
root
=
get_or_create_root
()
return
redirect
(
'wiki:get'
,
path
=
root
.
path
)
def
course_wiki_redirect
(
request
,
course_id
):
"""
This redirects to whatever page on the wiki that the course designates
as it's home page. A course's wiki must be an article on the root (for
example, "/6.002x") to keep things simple.
"""
course
=
check_course
(
course_id
)
namespace
=
course
.
wiki_namespace
#TODO: Make sure this is a legal slug. No "/"'s
try
:
urlpath
=
URLPath
.
get_by_path
(
namespace
,
select_related
=
True
)
results
=
list
(
Article
.
objects
.
filter
(
id
=
urlpath
.
article
.
id
)
)
if
results
:
article
=
results
[
0
]
else
:
article
=
None
except
(
NoRootURL
,
URLPath
.
DoesNotExist
):
# We will create it in the next block
urlpath
=
None
article
=
None
if
not
article
:
# create it
root
=
get_or_create_root
()
if
urlpath
:
# Somehow we got a urlpath without an article. Just delete it and
# recerate it.
urlpath
.
delete
()
urlpath
=
URLPath
.
create_article
(
root
,
namespace
,
title
=
course
.
title
,
content
=
"This is the wiki for "
+
course
.
title
+
"."
,
user_message
=
"Course page automatically created."
,
user
=
None
,
ip_address
=
None
,
article_kwargs
=
{
'owner'
:
None
,
'group'
:
None
,
'group_read'
:
True
,
'group_write'
:
True
,
'other_read'
:
True
,
'other_write'
:
True
,
})
return
redirect
(
"wiki:get"
,
path
=
urlpath
.
path
)
def
get_or_create_root
():
"""
Returns the root article, or creates it if it doesn't exist.
"""
try
:
root
=
URLPath
.
root
()
if
not
root
.
article
:
root
.
delete
()
raise
NoRootURL
return
root
except
NoRootURL
:
pass
starting_content
=
"
\n
"
.
join
((
"Welcome to the edX Wiki"
,
"==="
,
"Visit a course wiki to add an article."
))
root
=
URLPath
.
create_root
(
title
=
"edX Wiki"
,
content
=
starting_content
)
return
root
lms/envs/common.py
View file @
a2841af8
...
...
@@ -530,6 +530,7 @@ INSTALLED_APPS = (
#For the wiki
'wiki'
,
# The new django-wiki from benjaoming
'course_wiki'
,
# Our customizations
'django_notify'
,
'mptt'
,
'sekizai'
,
...
...
lms/urls.py
View file @
a2841af8
...
...
@@ -151,8 +151,12 @@ if settings.WIKI_ENABLED:
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/wiki/', include('simplewiki.urls')),
# )
urlpatterns
+=
(
#url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/wiki/', include('simplewiki.urls')),
# First we include views from course_wiki that we use to override the default views.
# They come first in the urlpatterns so they get resolved first
url
(
'^wiki/create-root/$'
,
'course_wiki.views.root_create'
,
name
=
'root_create'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/wiki$'
,
'course_wiki.views.course_wiki_redirect'
,
name
=
"course_wiki"
),
url
(
r'wiki/'
,
include
(
wiki_pattern
())),
url
(
r'^notify/'
,
include
(
notify_pattern
())),
...
...
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