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
e1c6801d
Unverified
Commit
e1c6801d
authored
4 years ago
by
Diane Kaplan
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Hide financial assistance link for two cases
parent
47d15ff1
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/courseware/course_tools.py
+8
-1
8 additions, 1 deletion
lms/djangoapps/courseware/course_tools.py
lms/djangoapps/courseware/tests/test_course_tools.py
+34
-4
34 additions, 4 deletions
lms/djangoapps/courseware/tests/test_course_tools.py
with
42 additions
and
5 deletions
lms/djangoapps/courseware/course_tools.py
+
8
−
1
View file @
e1c6801d
...
...
@@ -114,11 +114,18 @@ class FinancialAssistanceTool(CourseTool):
if
not
request
.
user
or
not
CourseEnrollment
.
is_enrolled
(
request
.
user
,
course_key
):
return
False
# hide if there's a course_upgrade_enrollment in the past
enrollment
=
CourseEnrollment
.
get_enrollment
(
request
.
user
,
course_key
)
# hide if we're no longer in an upsell mode (already upgraded)
if
enrollment
.
mode
not
in
CourseMode
.
UPSELL_TO_VERIFIED_MODES
:
return
False
# hide if there's no course_upgrade_deadline, or one with a value in the past
if
enrollment
.
course_upgrade_deadline
:
if
now
>
enrollment
.
course_upgrade_deadline
:
return
False
else
:
return
False
return
bool
(
course_overview
.
eligible_for_financial_aid
)
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/tests/test_course_tools.py
+
34
−
4
View file @
e1c6801d
...
...
@@ -137,14 +137,31 @@ class FinancialAssistanceToolTest(SharedModuleStoreTestCase):
self
.
request
=
RequestFactory
().
request
()
crum
.
set_current_request
(
self
.
request
)
self
.
addCleanup
(
crum
.
set_current_request
,
None
)
# baseline course enrollment, future upgrade deadline
self
.
enrollment
=
CourseEnrollmentFactory
(
course_id
=
self
.
course
.
id
,
mode
=
CourseMode
.
AUDIT
,
course
=
self
.
course_overview
,
)
self
.
request
.
user
=
self
.
enrollment
.
user
self
.
enrollment
.
course_upgrade_deadline
=
self
.
now
-
datetime
.
timedelta
(
days
=
1
)
self
.
enrollment
.
save
()
# enrollment where learner has upgraded
self
.
enrollment_upgraded
=
CourseEnrollmentFactory
(
course_id
=
self
.
course
.
id
,
mode
=
CourseMode
.
VERIFIED
,
course
=
self
.
course_overview
,
)
# course enrollment for mock: upgrade deadline in the past
self
.
enrollment_deadline_past
=
self
.
enrollment
self
.
enrollment_deadline_past
.
course_upgrade_deadline
=
self
.
now
-
datetime
.
timedelta
(
days
=
1
)
self
.
enrollment_deadline_past
.
save
()
# course enrollment for mock: no upgrade deadline
self
.
enrollment_deadline_missing
=
self
.
enrollment
self
.
enrollment_deadline_missing
.
course_upgrade_deadline
=
None
self
.
enrollment_deadline_missing
.
save
()
def
test_tool_visible_logged_in
(
self
):
self
.
course_financial_mode
.
save
()
...
...
@@ -155,7 +172,7 @@ class FinancialAssistanceToolTest(SharedModuleStoreTestCase):
self
.
course_overview
.
save
()
self
.
assertFalse
(
FinancialAssistanceTool
().
is_enabled
(
self
.
request
,
self
.
course_overview
.
id
))
def
test_tool_not_visible_when_user_not_
u
nrolled
(
self
):
def
test_tool_not_visible_when_user_not_
e
nrolled
(
self
):
self
.
course_financial_mode
.
save
()
self
.
request
.
user
=
None
self
.
assertFalse
(
FinancialAssistanceTool
().
is_enabled
(
self
.
request
,
self
.
course
.
id
))
...
...
@@ -163,10 +180,23 @@ class FinancialAssistanceToolTest(SharedModuleStoreTestCase):
# mock the response from get_enrollment to use enrollment with course_upgrade_deadline in the past
@patch
(
'
lms.djangoapps.courseware.course_tools.CourseEnrollment.get_enrollment
'
)
def
test_not_visible_when_upgrade_deadline_has_passed
(
self
,
get_enrollment_mock
):
get_enrollment_mock
.
return_value
=
self
.
enrollment
get_enrollment_mock
.
return_value
=
self
.
enrollment_deadline_past
self
.
assertFalse
(
FinancialAssistanceTool
().
is_enabled
(
self
.
request
,
self
.
course
.
id
))
# mock the response from get_enrollment to use enrollment with no course_upgrade_deadline
@patch
(
'
lms.djangoapps.courseware.course_tools.CourseEnrollment.get_enrollment
'
)
def
test_not_visible_when_no_upgrade_deadline
(
self
,
get_enrollment_mock
):
get_enrollment_mock
.
return_value
=
self
.
enrollment_deadline_missing
self
.
assertFalse
(
FinancialAssistanceTool
().
is_enabled
(
self
.
request
,
self
.
course
.
id
))
def
test_tool_not_visible_when_end_date_passed
(
self
):
self
.
course_overview
.
end_date
=
self
.
now
-
datetime
.
timedelta
(
days
=
30
)
self
.
course_overview
.
save
()
self
.
assertFalse
(
FinancialAssistanceTool
().
is_enabled
(
self
.
request
,
self
.
course_overview
.
id
))
# mock the response from get_enrollment to use enrollment where learner upgraded
@patch
(
'
lms.djangoapps.courseware.course_tools.CourseEnrollment.get_enrollment
'
)
def
test_tool_not_visible_when_already_upgraded
(
self
,
get_enrollment_mock
):
self
.
course_financial_mode
.
save
()
get_enrollment_mock
.
return_value
=
self
.
enrollment_upgraded
self
.
assertFalse
(
FinancialAssistanceTool
().
is_enabled
(
self
.
request
,
self
.
course
.
id
))
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