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
128d4836
Commit
128d4836
authored
Oct 22, 2014
by
stephensanchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change design to check for min price or suggested prices.
parent
de4a2191
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
2 deletions
+40
-2
common/djangoapps/course_modes/models.py
+19
-0
common/djangoapps/course_modes/tests/test_models.py
+19
-0
common/djangoapps/student/views.py
+2
-2
No files found.
common/djangoapps/course_modes/models.py
View file @
128d4836
...
...
@@ -164,6 +164,25 @@ class CourseMode(models.Model):
return
0
@classmethod
def
has_payment_options
(
cls
,
course_id
):
"""Determines if there is any mode that has payment options
Check the dict of course modes and see if any of them have a minimum price or
suggested prices. Returns True if any course mode has a payment option.
Args:
course_mode_dict (dict): Dictionary mapping course mode slugs to Modes
Returns:
True if any course mode has a payment option.
"""
for
mode
in
cls
.
modes_for_course
(
course_id
):
if
mode
.
min_price
>
0
or
mode
.
suggested_prices
!=
''
:
return
True
return
False
@classmethod
def
min_course_price_for_currency
(
cls
,
course_id
,
currency
):
"""
Returns the minimum price of the course in the appropriate currency over all the course's
...
...
common/djangoapps/course_modes/tests/test_models.py
View file @
128d4836
...
...
@@ -127,3 +127,22 @@ class CourseModeModelTest(TestCase):
mode
=
CourseMode
.
verified_mode_for_course
(
self
.
course_key
)
self
.
assertEqual
(
mode
.
slug
,
'professional'
)
def
test_course_has_payment_options
(
self
):
# Has no payment options.
honor
,
_
=
self
.
create_mode
(
'honor'
,
'Honor'
)
self
.
assertFalse
(
CourseMode
.
has_payment_options
(
self
.
course_key
))
# Now we do have a payment option.
verified
,
_
=
self
.
create_mode
(
'verified'
,
'Verified'
,
min_price
=
5
)
self
.
assertTrue
(
CourseMode
.
has_payment_options
(
self
.
course_key
))
# Unset verified's minimum price.
verified
.
min_price
=
0
verified
.
save
()
self
.
assertFalse
(
CourseMode
.
has_payment_options
(
self
.
course_key
))
# Finally, give the honor mode payment options
honor
.
suggested_prices
=
'5, 10, 15'
honor
.
save
()
self
.
assertTrue
(
CourseMode
.
has_payment_options
(
self
.
course_key
))
common/djangoapps/student/views.py
View file @
128d4836
...
...
@@ -699,8 +699,8 @@ def _allow_donation(course_modes, course_id):
"""
donations_enabled
=
DonationConfiguration
.
current
()
.
enabled
is_verified_mode
=
CourseMode
.
has_verified_mode
(
course_modes
[
course_id
])
is_microsite
=
microsite
.
is_request_in_microsite
(
)
return
donations_enabled
and
not
is_verified_mode
and
not
is_microsite
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
):
...
...
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