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
23ee963c
Commit
23ee963c
authored
Apr 28, 2014
by
Adam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3476 from edx/usman/lms2556-wiki-urls
Fixed transform_url function in WikiAccessMiddleware.
parents
7a513820
f591b1db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
5 deletions
+40
-5
lms/djangoapps/course_wiki/middleware.py
+4
-5
lms/djangoapps/course_wiki/tests/test_middleware.py
+36
-0
No files found.
lms/djangoapps/course_wiki/middleware.py
View file @
23ee963c
...
@@ -52,11 +52,10 @@ class WikiAccessMiddleware(object):
...
@@ -52,11 +52,10 @@ class WikiAccessMiddleware(object):
return
redirect
(
reverse
(
'accounts_login'
),
next
=
request
.
path
)
return
redirect
(
reverse
(
'accounts_login'
),
next
=
request
.
path
)
if
course_id
:
if
course_id
:
# this is a /course/123/wiki request
# This is a /courses/org/name/run/wiki request
my_url
=
request
.
path
.
replace
(
wiki_path
,
''
)
.
replace
(
'/wiki/'
,
''
)
# HACK: django-wiki monkeypatches the django reverse function to enable urls to be rewritten
# HACK: django-wiki monkeypatches the reverse function to enable
url_prefix
=
"/courses/{0}"
.
format
(
course_id
)
# urls to be rewritten
reverse
.
_transform_url
=
lambda
url
:
url_prefix
+
url
# pylint: disable=protected-access
reverse
.
_transform_url
=
lambda
url
:
my_url
+
url
# pylint: disable=W0212
# Authorization Check
# Authorization Check
# Let's see if user is enrolled or the course allows for public access
# Let's see if user is enrolled or the course allows for public access
try
:
try
:
...
...
lms/djangoapps/course_wiki/tests/test_middleware.py
0 → 100644
View file @
23ee963c
"""
Tests for wiki middleware.
"""
from
django.test.client
import
Client
from
django.test.utils
import
override_settings
from
wiki.models
import
URLPath
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
courseware.tests.factories
import
InstructorFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
course_wiki.views
import
get_or_create_root
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
TestWikiAccessMiddleware
(
ModuleStoreTestCase
):
"""Tests for WikiAccessMiddleware."""
def
setUp
(
self
):
"""Test setup."""
self
.
wiki
=
get_or_create_root
()
self
.
course_math101
=
CourseFactory
.
create
(
org
=
'edx'
,
number
=
'math101'
,
display_name
=
'2014'
,
metadata
=
{
'use_unique_wiki_id'
:
'false'
})
self
.
course_math101_instructor
=
InstructorFactory
(
course
=
self
.
course_math101
.
location
,
username
=
'instructor'
,
password
=
'secret'
)
self
.
wiki_math101
=
URLPath
.
create_article
(
self
.
wiki
,
'math101'
,
title
=
'math101'
)
self
.
client
=
Client
()
self
.
client
.
login
(
username
=
'instructor'
,
password
=
'secret'
)
def
test_url_tranform
(
self
):
"""Test that the correct prefix ('/courses/<course_id>') is added to the urls in the wiki."""
response
=
self
.
client
.
get
(
'/courses/edx/math101/2014/wiki/math101/'
)
self
.
assertIn
(
'/courses/edx/math101/2014/wiki/math101/_edit/'
,
response
.
content
)
self
.
assertIn
(
'/courses/edx/math101/2014/wiki/math101/_settings/'
,
response
.
content
)
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