Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
d02efb1d
Unverified
Commit
d02efb1d
authored
6 years ago
by
Zia Fazal
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #19604 from edx/ziafazal/WL-1660
WL-1660: Added ability to stop redirect to course home page
parents
7d0cf7f2
0e1fff31
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/courseware/tests/test_about.py
+28
-0
28 additions, 0 deletions
lms/djangoapps/courseware/tests/test_about.py
lms/djangoapps/courseware/views/views.py
+19
-4
19 additions, 4 deletions
lms/djangoapps/courseware/views/views.py
with
47 additions
and
4 deletions
lms/djangoapps/courseware/tests/test_about.py
+
28
−
0
View file @
d02efb1d
...
...
@@ -140,6 +140,34 @@ class AboutTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase, EventTra
course_home_url
=
reverse
(
'
openedx.course_experience.course_home
'
,
args
=
[
text_type
(
self
.
course
.
id
)])
self
.
assertTrue
(
target_url
.
endswith
(
course_home_url
))
@patch.dict
(
settings
.
FEATURES
,
{
'
ENABLE_COURSE_HOME_REDIRECT
'
:
False
})
@patch.dict
(
settings
.
FEATURES
,
{
'
ENABLE_MKTG_SITE
'
:
True
})
def
test_logged_in_marketing_without_course_home_redirect
(
self
):
"""
Verify user is not redirected to course home page when
ENABLE_COURSE_HOME_REDIRECT is set to False
"""
self
.
setup_user
()
url
=
reverse
(
'
about_course
'
,
args
=
[
text_type
(
self
.
course
.
id
)])
resp
=
self
.
client
.
get
(
url
)
# should not be redirected
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
"
OOGIE BLOOGIE
"
,
resp
.
content
)
@patch.dict
(
settings
.
FEATURES
,
{
'
ENABLE_COURSE_HOME_REDIRECT
'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'
ENABLE_MKTG_SITE
'
:
False
})
def
test_logged_in_marketing_without_mktg_site
(
self
):
"""
Verify user is not redirected to course home page when
ENABLE_MKTG_SITE is set to False
"""
self
.
setup_user
()
url
=
reverse
(
'
about_course
'
,
args
=
[
text_type
(
self
.
course
.
id
)])
resp
=
self
.
client
.
get
(
url
)
# should not be redirected
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
"
OOGIE BLOOGIE
"
,
resp
.
content
)
@patch.dict
(
settings
.
FEATURES
,
{
'
ENABLE_PREREQUISITE_COURSES
'
:
True
})
def
test_pre_requisite_course
(
self
):
pre_requisite_course
=
CourseFactory
.
create
(
org
=
'
edX
'
,
course
=
'
900
'
,
display_name
=
'
pre requisite course
'
)
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/views/views.py
+
19
−
4
View file @
d02efb1d
...
...
@@ -759,15 +759,15 @@ def course_about(request, course_id):
if
not
can_self_enroll_in_course
(
course_key
):
return
redirect
(
reverse
(
'
dashboard
'
))
# If user needs to be redirected to course home then redirect
if
_course_home_redirect_enabled
():
return
redirect
(
reverse
(
course_home_url_name
(
course_key
),
args
=
[
text_type
(
course_key
)]))
with
modulestore
().
bulk_operations
(
course_key
):
permission
=
get_permission_for_course_about
()
course
=
get_course_with_access
(
request
.
user
,
permission
,
course_key
)
course_details
=
CourseDetails
.
populate
(
course
)
modes
=
CourseMode
.
modes_for_course_dict
(
course_key
)
if
configuration_helpers
.
get_value
(
'
ENABLE_MKTG_SITE
'
,
settings
.
FEATURES
.
get
(
'
ENABLE_MKTG_SITE
'
,
False
)):
return
redirect
(
reverse
(
course_home_url_name
(
course
.
id
),
args
=
[
text_type
(
course
.
id
)]))
registered
=
registered_for_course
(
course
,
request
.
user
)
staff_access
=
bool
(
has_access
(
request
.
user
,
'
staff
'
,
course
))
...
...
@@ -1138,6 +1138,21 @@ def _credit_course_requirements(course_key, student):
}
def
_course_home_redirect_enabled
():
"""
Return True value if user needs to be redirected to course home based on value of
`ENABLE_MKTG_SITE` and `ENABLE_COURSE_HOME_REDIRECT feature` flags
Returns: boolean True or False
"""
if
configuration_helpers
.
get_value
(
'
ENABLE_MKTG_SITE
'
,
settings
.
FEATURES
.
get
(
'
ENABLE_MKTG_SITE
'
,
False
)
)
and
configuration_helpers
.
get_value
(
'
ENABLE_COURSE_HOME_REDIRECT
'
,
settings
.
FEATURES
.
get
(
'
ENABLE_COURSE_HOME_REDIRECT
'
,
True
)
):
return
True
@login_required
@ensure_valid_course_key
def
submission_history
(
request
,
course_id
,
student_username
,
location
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment