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
7bdbf8f1
Commit
7bdbf8f1
authored
Jan 09, 2015
by
arbisoft
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ECOM-528 added donation support for verified courses
parent
99659ce3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
10 deletions
+109
-10
common/djangoapps/student/tests/test_recent_enrollments.py
+102
-8
common/djangoapps/student/views.py
+7
-2
No files found.
common/djangoapps/student/tests/test_recent_enrollments.py
View file @
7bdbf8f1
...
@@ -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. """
...
@@ -127,15 +127,43 @@ class TestRecentEnrollments(ModuleStoreTestCase):
...
@@ -127,15 +127,43 @@ 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
),
# (['audit', 'honor'], 'honor', False),
([
'professional'
],
False
),
([
'professional'
],
'honor'
,
True
),
([
'verified'
],
False
),
([
'verified'
],
'honor'
,
True
),
([
'audit'
],
True
),
([
'professional'
,
'verified'
],
'honor'
,
True
),
([
'honor'
],
True
),
([
'audit'
,
'honor'
,
'professional'
],
'honor'
,
True
),
([],
True
)
([
'audit'
,
'honor'
,
'verified'
],
'honor'
,
True
),
([
'audit'
,
'honor'
,
'verified'
,
'professional'
],
'honor'
,
True
),
# (['audit'], 'honor', False),
# (['honor'], 'honor', False),
# ([], 'honor', False),
#
# (['audit', 'honor'], 'audit', False),
# (['professional'], 'audit', True),
# (['verified'], 'audit', True),
# (['professional', 'verified'], 'audit', True),
# (['audit', 'honor', 'professional'], 'audit', True),
# (['audit', 'honor', 'verified'], 'audit', True),
# (['audit', 'honor', 'verified', 'professional'], 'audit', True),
# (['audit'], 'audit', True),
# (['honor'], 'audit', True),
# ([], 'audit', True),
# (['audit', 'honor'], 'verified', False),
([
'professional'
],
'verified'
,
False
),
([
'verified'
],
'verified'
,
False
),
([
'professional'
,
'verified'
],
'verified'
,
False
),
([
'audit'
,
'honor'
,
'professional'
],
'verified'
,
False
),
([
'audit'
,
'honor'
,
'verified'
],
'verified'
,
False
),
([
'audit'
,
'honor'
,
'verified'
,
'professional'
],
'verified'
,
False
),
# (['audit'], 'verified', False),
# (['honor'], 'verified', False),
# ([], '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
):
from
nose.tools
import
set_trace
;
set_trace
()
# Enable the enrollment success message
# Enable the enrollment success message
self
.
_configure_message_timeout
(
10000
)
self
.
_configure_message_timeout
(
10000
)
...
@@ -146,6 +174,9 @@ class TestRecentEnrollments(ModuleStoreTestCase):
...
@@ -146,6 +174,9 @@ class TestRecentEnrollments(ModuleStoreTestCase):
for
mode
in
course_modes
:
for
mode
in
course_modes
:
CourseModeFactory
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
)
CourseModeFactory
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
)
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
)
response
=
self
.
client
.
get
(
reverse
(
"dashboard"
))
response
=
self
.
client
.
get
(
reverse
(
"dashboard"
))
...
@@ -155,6 +186,69 @@ class TestRecentEnrollments(ModuleStoreTestCase):
...
@@ -155,6 +186,69 @@ class TestRecentEnrollments(ModuleStoreTestCase):
else
:
else
:
self
.
assertNotContains
(
response
,
"donate-container"
)
self
.
assertNotContains
(
response
,
"donate-container"
)
# @ddt.data(
# (['audit', 'honor'], True),
# (['professional'], True),
# (['verified'], True),
# (['audit'], True),
# (['honor'], True),
# ([], True)
# )
# @ddt.unpack
# def test_donate_button_enrollment_audit(self, course_modes, show_donate):
# from nose.tools import set_trace; set_trace()
# # Enable the enrollment success message
# self._configure_message_timeout(10000)
#
# # Enable donations
# DonationConfiguration(enabled=True).save()
#
# # Create the course mode(s)
# for mode in course_modes:
# CourseModeFactory(mode_slug=mode, course_id=self.course.id)
# self.enrollment.mode = 'audit'
# self.enrollment.save()
# # Check that the donate button is or is not displayed
# self.client.login(username=self.student.username, password=self.PASSWORD)
# response = self.client.get(reverse("dashboard"))
#
# if show_donate:
# self.assertContains(response, "donate-container")
# else:
# self.assertNotContains(response, "donate-container")
#
# @ddt.data(
# (['audit', 'honor'], True),
# (['professional'], True),
# (['verified'], True),
# (['audit'], True),
# (['honor'], True),
# ([], True)
# )
# @ddt.unpack
# def test_donate_button_verified_courses(self, course_modes, show_donate):
# from nose.tools import set_trace; set_trace()
# # Enable the enrollment success message
# self._configure_message_timeout(10000)
#
# # Enable donations
# DonationConfiguration(enabled=True).save()
#
# # Create the course mode(s)
# for mode in course_modes:
# CourseModeFactory(mode_slug=mode, course_id=self.course.id)
#
# self.enrollment.mode = ''
#
# # Check that the donate button is or is not displayed
# self.client.login(username=self.student.username, password=self.PASSWORD)
# response = self.client.get(reverse("dashboard"))
#
# if show_donate:
# self.assertContains(response, "donate-container")
# else:
# self.assertNotContains(response, "donate-container")
def
test_donate_button_honor_with_price
(
self
):
def
test_donate_button_honor_with_price
(
self
):
# Enable the enrollment success message and donations
# Enable the enrollment success message and donations
self
.
_configure_message_timeout
(
10000
)
self
.
_configure_message_timeout
(
10000
)
...
...
common/djangoapps/student/views.py
View file @
7bdbf8f1
...
@@ -738,7 +738,7 @@ def _get_recently_enrolled_courses(course_enrollment_pairs):
...
@@ -738,7 +738,7 @@ 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
...
@@ -758,10 +758,15 @@ def _allow_donation(course_modes, course_id, enrollment):
...
@@ -758,10 +758,15 @@ def _allow_donation(course_modes, course_id, enrollment):
True if the course is allowing donations.
True if the course is allowing donations.
"""
"""
# from nose.tools import set_trace;
# set_trace()
donations_enabled
=
DonationConfiguration
.
current
()
.
enabled
donations_enabled
=
DonationConfiguration
.
current
()
.
enabled
is_verified_mode
=
CourseMode
.
has_verified_mode
(
course_modes
[
course_id
])
is_verified_mode
=
CourseMode
.
has_verified_mode
(
course_modes
[
course_id
])
has_payment_option
=
CourseMode
.
has_payment_options
(
course_id
)
has_payment_option
=
CourseMode
.
has_payment_options
(
course_id
)
return
donations_enabled
and
(
not
is_verified_mode
or
(
is_verified_mode
and
enrollment
.
mode
in
[
'audit'
,
'honor'
])
)
and
not
has_payment_option
return_val
=
donations_enabled
and
(
not
is_verified_mode
or
(
is_verified_mode
and
enrollment
.
mode
in
[
'audit'
,
'honor'
]))
and
not
has_payment_option
return_val
#TODO Hard coded for the time being
return
True
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