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
ab06f37c
Commit
ab06f37c
authored
Jan 12, 2015
by
Aamir
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6521 from edx/aamir-khan/ECOM-528-donation-verified-courses
Aamir khan/ecom 528 donation verified courses
parents
80e0d56a
62ea4865
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
21 deletions
+37
-21
common/djangoapps/student/tests/test_recent_enrollments.py
+31
-14
common/djangoapps/student/views.py
+6
-7
No files found.
common/djangoapps/student/tests/test_recent_enrollments.py
View file @
ab06f37c
...
@@ -43,7 +43,7 @@ class TestRecentEnrollments(ModuleStoreTestCase):
...
@@ -43,7 +43,7 @@ class TestRecentEnrollments(ModuleStoreTestCase):
# New Course
# New Course
course_location
=
locator
.
CourseLocator
(
'Org1'
,
'Course1'
,
'Run1'
)
course_location
=
locator
.
CourseLocator
(
'Org1'
,
'Course1'
,
'Run1'
)
self
.
course
,
_
=
self
.
_create_course_and_enrollment
(
course_location
)
self
.
course
,
self
.
enrollment
=
self
.
_create_course_and_enrollment
(
course_location
)
def
_create_course_and_enrollment
(
self
,
course_location
):
def
_create_course_and_enrollment
(
self
,
course_location
):
""" Creates a course and associated enrollment. """
""" Creates a course and associated enrollment. """
...
@@ -112,10 +112,10 @@ class TestRecentEnrollments(ModuleStoreTestCase):
...
@@ -112,10 +112,10 @@ class TestRecentEnrollments(ModuleStoreTestCase):
recent_course_list
=
_get_recently_enrolled_courses
(
courses_list
)
recent_course_list
=
_get_recently_enrolled_courses
(
courses_list
)
self
.
assertEqual
(
len
(
recent_course_list
),
5
)
self
.
assertEqual
(
len
(
recent_course_list
),
5
)
self
.
assertEqual
(
recent_course_list
[
1
],
courses
[
0
])
self
.
assertEqual
(
recent_course_list
[
1
]
[
0
]
,
courses
[
0
])
self
.
assertEqual
(
recent_course_list
[
2
],
courses
[
1
])
self
.
assertEqual
(
recent_course_list
[
2
]
[
0
]
,
courses
[
1
])
self
.
assertEqual
(
recent_course_list
[
3
],
courses
[
2
])
self
.
assertEqual
(
recent_course_list
[
3
]
[
0
]
,
courses
[
2
])
self
.
assertEqual
(
recent_course_list
[
4
],
courses
[
3
])
self
.
assertEqual
(
recent_course_list
[
4
]
[
0
]
,
courses
[
3
])
def
test_dashboard_rendering
(
self
):
def
test_dashboard_rendering
(
self
):
"""
"""
...
@@ -127,15 +127,29 @@ class TestRecentEnrollments(ModuleStoreTestCase):
...
@@ -127,15 +127,29 @@ class TestRecentEnrollments(ModuleStoreTestCase):
self
.
assertContains
(
response
,
"Thank you for enrolling in"
)
self
.
assertContains
(
response
,
"Thank you for enrolling in"
)
@ddt.data
(
@ddt.data
(
([
'audit'
,
'honor'
,
'verified'
],
False
),
#Register as an honor in any course modes with no payment option
([
'professional'
],
False
),
([(
'audit'
,
0
),
(
'honor'
,
0
)],
'honor'
,
True
),
([
'verified'
],
False
),
([(
'honor'
,
0
)],
'honor'
,
True
),
([
'audit'
],
True
),
([],
'honor'
,
True
),
([
'honor'
],
True
),
#Register as an honor in any course modes which has payment option
([],
True
)
([(
'honor'
,
10
)],
'honor'
,
False
),
# This is a paid course
([(
'audit'
,
0
),
(
'honor'
,
0
),
(
'professional'
,
20
)],
'honor'
,
True
),
([(
'audit'
,
0
),
(
'honor'
,
0
),
(
'verified'
,
20
)],
'honor'
,
True
),
([(
'audit'
,
0
),
(
'honor'
,
0
),
(
'verified'
,
20
),
(
'professional'
,
20
)],
'honor'
,
True
),
([],
'honor'
,
True
),
#Register as an audit in any course modes with no payment option
([(
'audit'
,
0
),
(
'honor'
,
0
)],
'audit'
,
True
),
([(
'audit'
,
0
)],
'audit'
,
True
),
#Register as an audit in any course modes which has no payment option
([(
'audit'
,
0
),
(
'honor'
,
0
),
(
'verified'
,
10
)],
'audit'
,
True
),
#Register as a verified in any course modes which has payment option
([(
'professional'
,
20
)],
'professional'
,
False
),
([(
'verified'
,
20
)],
'verified'
,
False
),
([(
'professional'
,
20
),
(
'verified'
,
20
)],
'verified'
,
False
),
([(
'audit'
,
0
),
(
'honor'
,
0
),
(
'verified'
,
20
)],
'verified'
,
False
)
)
)
@ddt.unpack
@ddt.unpack
def
test_donate_button
(
self
,
course_modes
,
show_donate
):
def
test_donate_button
(
self
,
course_modes
,
enrollment_mode
,
show_donate
):
# Enable the enrollment success message
# Enable the enrollment success message
self
.
_configure_message_timeout
(
10000
)
self
.
_configure_message_timeout
(
10000
)
...
@@ -143,8 +157,11 @@ class TestRecentEnrollments(ModuleStoreTestCase):
...
@@ -143,8 +157,11 @@ class TestRecentEnrollments(ModuleStoreTestCase):
DonationConfiguration
(
enabled
=
True
)
.
save
()
DonationConfiguration
(
enabled
=
True
)
.
save
()
# Create the course mode(s)
# Create the course mode(s)
for
mode
in
course_modes
:
for
mode
,
min_price
in
course_modes
:
CourseModeFactory
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
)
CourseModeFactory
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
,
min_price
=
min_price
)
self
.
enrollment
.
mode
=
enrollment_mode
self
.
enrollment
.
save
()
# Check that the donate button is or is not displayed
# Check that the donate button is or is not displayed
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
self
.
PASSWORD
)
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
self
.
PASSWORD
)
...
...
common/djangoapps/student/views.py
View file @
ab06f37c
...
@@ -712,9 +712,9 @@ def _create_recent_enrollment_message(course_enrollment_pairs, course_modes):
...
@@ -712,9 +712,9 @@ def _create_recent_enrollment_message(course_enrollment_pairs, course_modes):
{
{
"course_id"
:
course
.
id
,
"course_id"
:
course
.
id
,
"course_name"
:
course
.
display_name
,
"course_name"
:
course
.
display_name
,
"allow_donation"
:
_allow_donation
(
course_modes
,
course
.
id
)
"allow_donation"
:
_allow_donation
(
course_modes
,
course
.
id
,
enrollment
)
}
}
for
course
in
recently_enrolled_courses
for
course
,
enrollment
in
recently_enrolled_courses
]
]
return
render_to_string
(
return
render_to_string
(
...
@@ -738,14 +738,14 @@ def _get_recently_enrolled_courses(course_enrollment_pairs):
...
@@ -738,14 +738,14 @@ def _get_recently_enrolled_courses(course_enrollment_pairs):
seconds
=
DashboardConfiguration
.
current
()
.
recent_enrollment_time_delta
seconds
=
DashboardConfiguration
.
current
()
.
recent_enrollment_time_delta
time_delta
=
(
datetime
.
datetime
.
now
(
UTC
)
-
datetime
.
timedelta
(
seconds
=
seconds
))
time_delta
=
(
datetime
.
datetime
.
now
(
UTC
)
-
datetime
.
timedelta
(
seconds
=
seconds
))
return
[
return
[
course
for
course
,
enrollment
in
course_enrollment_pairs
(
course
,
enrollment
)
for
course
,
enrollment
in
course_enrollment_pairs
# If the enrollment has no created date, we are explicitly excluding the course
# If the enrollment has no created date, we are explicitly excluding the course
# from the list of recent enrollments.
# from the list of recent enrollments.
if
enrollment
.
is_active
and
enrollment
.
created
>
time_delta
if
enrollment
.
is_active
and
enrollment
.
created
>
time_delta
]
]
def
_allow_donation
(
course_modes
,
course_id
):
def
_allow_donation
(
course_modes
,
course_id
,
enrollment
):
"""Determines if the dashboard will request donations for the given course.
"""Determines if the dashboard will request donations for the given course.
Check if donations are configured for the platform, and if the current course is accepting donations.
Check if donations are configured for the platform, and if the current course is accepting donations.
...
@@ -753,15 +753,14 @@ def _allow_donation(course_modes, course_id):
...
@@ -753,15 +753,14 @@ def _allow_donation(course_modes, course_id):
Args:
Args:
course_modes (dict): Mapping of course ID's to course mode dictionaries.
course_modes (dict): Mapping of course ID's to course mode dictionaries.
course_id (str): The unique identifier for the course.
course_id (str): The unique identifier for the course.
enrollment(CourseEnrollment): The enrollment object in which the user is enrolled
Returns:
Returns:
True if the course is allowing donations.
True if the course is allowing donations.
"""
"""
donations_enabled
=
DonationConfiguration
.
current
()
.
enabled
donations_enabled
=
DonationConfiguration
.
current
()
.
enabled
is_verified_mode
=
CourseMode
.
has_verified_mode
(
course_modes
[
course_id
])
return
donations_enabled
and
enrollment
.
mode
in
course_modes
[
course_id
]
and
course_modes
[
course_id
][
enrollment
.
mode
]
.
min_price
==
0
has_payment_option
=
CourseMode
.
has_payment_options
(
course_id
)
return
donations_enabled
and
not
is_verified_mode
and
not
has_payment_option
def
try_change_enrollment
(
request
):
def
try_change_enrollment
(
request
):
...
...
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