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
9f770ef9
Commit
9f770ef9
authored
Aug 14, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Visiting the wiki from a course you aren't in does a redirect to the regular wiki.
parent
ceaa6a4f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
lms/djangoapps/course_wiki/course_nav.py
+22
-2
lms/urls.py
+2
-2
No files found.
lms/djangoapps/course_wiki/course_nav.py
View file @
9f770ef9
...
...
@@ -14,6 +14,10 @@ class Middleware(object):
If it intercepts a request for /wiki/.. that has a referrer in the
form /courses/course_id/... it will redirect the user to the page
/courses/course_id/wiki/...
It is also possible that someone followed a link leading to a course
that they don't have access to. In this case, we redirect them to the
same page on the regular wiki.
"""
def
process_request
(
self
,
request
):
...
...
@@ -37,12 +41,28 @@ class Middleware(object):
# See if we are able to view the course. If we are, redirect to it
try
:
course
=
check_course
(
request
.
user
,
course_id
)
return
redirect
(
"/courses/"
+
course
.
id
+
"/
view_
wiki/"
+
path_match
.
group
(
'wiki_path'
)
)
return
redirect
(
"/courses/"
+
course
.
id
+
"/wiki/"
+
path_match
.
group
(
'wiki_path'
)
)
except
Http404
:
# Even though we came from the course, we can't see it. So don't worry about it.
pass
else
:
# It is also possible we are going to a course wiki view, but we
# don't have permission to see the course!
course_match
=
re
.
match
(
r'/courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/wiki/(?P<wiki_path>.*|)$'
,
request
.
path
)
if
course_match
:
course_id
=
course_match
.
group
(
'course_id'
)
# See if we are able to view the course. If we aren't, redirect to regular wiki
try
:
course
=
check_course
(
request
.
user
,
course_id
)
# Good, we can see the course. Carry on
return
None
except
Http404
:
# We can't see the course, so redirect to the regular wiki
return
redirect
(
"/wiki/"
+
course_match
.
group
(
'wiki_path'
))
return
None
def
context_processor
(
request
):
...
...
@@ -54,7 +74,7 @@ def context_processor(request):
bar to be shown.
"""
match
=
re
.
match
(
r'^/courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/
view_
wiki(?P<wiki_path>.*|)'
,
request
.
path
)
match
=
re
.
match
(
r'^/courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/wiki(?P<wiki_path>.*|)'
,
request
.
path
)
if
match
:
course_id
=
match
.
group
(
'course_id'
)
...
...
lms/urls.py
View file @
9f770ef9
...
...
@@ -172,9 +172,9 @@ if settings.WIKI_ENABLED:
# These urls are for viewing the wiki in the context of a course. They should
# never be returned by a reverse() so they come after the other url patterns
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/wiki/?$'
,
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/
course_
wiki/?$'
,
'course_wiki.views.course_wiki_redirect'
,
name
=
"course_wiki"
),
url
(
r'^courses/(?:[^/]+/[^/]+/[^/]+)/
view_
wiki/'
,
include
(
wiki_pattern
())),
url
(
r'^courses/(?:[^/]+/[^/]+/[^/]+)/wiki/'
,
include
(
wiki_pattern
())),
)
if
settings
.
QUICKEDIT
:
...
...
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