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
932010df
Commit
932010df
authored
Jul 24, 2014
by
asadiqbal08
Committed by
Chris Dodge
Aug 05, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refund message for purchased courses
Add little more logic for paid courses
parent
33d5b49e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
8 deletions
+54
-8
common/djangoapps/student/models.py
+15
-0
common/djangoapps/student/tests/tests.py
+20
-5
common/djangoapps/student/views.py
+3
-0
lms/templates/dashboard.html
+2
-1
lms/templates/dashboard/_dashboard_course_listing.html
+14
-2
No files found.
common/djangoapps/student/models.py
View file @
932010df
...
...
@@ -18,6 +18,8 @@ from pytz import UTC
import
uuid
from
collections
import
defaultdict
from
dogapi
import
dog_stats_api
from
django.db.models
import
Q
import
pytz
from
django.conf
import
settings
from
django.utils
import
timezone
...
...
@@ -960,6 +962,17 @@ class CourseEnrollment(models.Model):
d
[
'total'
]
=
total
return
d
def
is_paid_course
(
self
):
"""
Returns True, if course is paid
"""
paid_course
=
CourseMode
.
objects
.
filter
(
Q
(
course_id
=
self
.
course_id
)
&
Q
(
mode_slug
=
'honor'
)
&
(
Q
(
expiration_datetime__isnull
=
True
)
|
Q
(
expiration_datetime__gte
=
datetime
.
now
(
pytz
.
UTC
))))
.
exclude
(
min_price
=
0
)
if
paid_course
:
return
True
return
False
def
activate
(
self
):
"""Makes this `CourseEnrollment` record active. Saves immediately."""
self
.
update_enrollment
(
is_active
=
True
)
...
...
@@ -991,6 +1004,8 @@ class CourseEnrollment(models.Model):
if
GeneratedCertificate
.
certificate_for_student
(
self
.
user
,
self
.
course_id
)
is
not
None
:
return
False
#TODO - When Course administrators to define a refund period for paid courses then refundable will be supported. # pylint: disable=W0511
course_mode
=
CourseMode
.
mode_for_course
(
self
.
course_id
,
'verified'
)
if
course_mode
is
None
:
return
False
...
...
common/djangoapps/student/tests/tests.py
View file @
932010df
...
...
@@ -148,11 +148,6 @@ class DashboardTest(TestCase):
self
.
course
=
CourseFactory
.
create
(
org
=
self
.
COURSE_ORG
,
display_name
=
self
.
COURSE_NAME
,
number
=
self
.
COURSE_SLUG
)
self
.
assertIsNotNone
(
self
.
course
)
self
.
user
=
UserFactory
.
create
(
username
=
"jack"
,
email
=
"jack@fake.edx.org"
,
password
=
'test'
)
CourseModeFactory
.
create
(
course_id
=
self
.
course
.
id
,
mode_slug
=
'honor'
,
mode_display_name
=
'Honor Code'
,
)
self
.
client
=
Client
()
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
...
...
@@ -231,6 +226,26 @@ class DashboardTest(TestCase):
self
.
assertFalse
(
enrollment
.
refundable
())
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_refundable_of_purchased_course
(
self
):
self
.
client
.
login
(
username
=
"jack"
,
password
=
"test"
)
CourseModeFactory
.
create
(
course_id
=
self
.
course
.
id
,
mode_slug
=
'honor'
,
min_price
=
10
,
currency
=
'usd'
,
mode_display_name
=
'honor'
,
expiration_datetime
=
datetime
.
now
(
pytz
.
UTC
)
+
timedelta
(
days
=
1
)
)
enrollment
=
CourseEnrollment
.
enroll
(
self
.
user
,
self
.
course
.
id
,
mode
=
'honor'
)
# TODO: Until we can allow course administrators to define a refund period for paid for courses show_refund_option should be False. # pylint: disable=W0511
self
.
assertFalse
(
enrollment
.
refundable
())
resp
=
self
.
client
.
post
(
reverse
(
'student.views.dashboard'
,
args
=
[]))
self
.
assertIn
(
'You will not be refunded the amount you paid.'
,
resp
.
content
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_refundable_when_certificate_exists
(
self
):
verified_mode
=
CourseModeFactory
.
create
(
course_id
=
self
.
course
.
id
,
...
...
common/djangoapps/student/views.py
View file @
932010df
...
...
@@ -483,6 +483,8 @@ def dashboard(request):
show_refund_option_for
=
frozenset
(
course
.
id
for
course
,
_enrollment
in
course_enrollment_pairs
if
_enrollment
.
refundable
())
enrolled_courses_either_paid
=
frozenset
(
course
.
id
for
course
,
_enrollment
in
course_enrollment_pairs
if
_enrollment
.
is_paid_course
())
# get info w.r.t ExternalAuthMap
external_auth_map
=
None
try
:
...
...
@@ -535,6 +537,7 @@ def dashboard(request):
'duplicate_provider'
:
None
,
'logout_url'
:
reverse
(
logout_user
),
'platform_name'
:
settings
.
PLATFORM_NAME
,
'enrolled_courses_either_paid'
:
enrolled_courses_either_paid
,
'provider_states'
:
[],
}
...
...
lms/templates/dashboard.html
View file @
932010df
...
...
@@ -302,7 +302,8 @@
<
%
show_email_settings =
(course.id
in
show_email_settings_for
)
%
>
<
%
course_mode_info =
all_course_modes.get(course.id)
%
>
<
%
show_refund_option =
(course.id
in
show_refund_option_for
)
%
>
<
%
include
file=
'dashboard/_dashboard_course_listing.html'
args=
"course=course, enrollment=enrollment, show_courseware_link=show_courseware_link, cert_status=cert_status, show_email_settings=show_email_settings, course_mode_info=course_mode_info, show_refund_option = show_refund_option"
/>
<
%
is_paid_course =
(course.id
in
enrolled_courses_either_paid
)
%
>
<
%
include
file=
'dashboard/_dashboard_course_listing.html'
args=
"course=course, enrollment=enrollment, show_courseware_link=show_courseware_link, cert_status=cert_status, show_email_settings=show_email_settings, course_mode_info=course_mode_info, show_refund_option = show_refund_option, is_paid_course = is_paid_course"
/>
% endfor
</ul>
...
...
lms/templates/dashboard/_dashboard_course_listing.html
View file @
932010df
<
%
page
args=
"course, enrollment, show_courseware_link, cert_status, show_email_settings, course_mode_info, show_refund_option"
/>
<
%
page
args=
"course, enrollment, show_courseware_link, cert_status, show_email_settings, course_mode_info, show_refund_option
, is_paid_course
"
/>
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%!
...
...
@@ -126,7 +126,19 @@
% endif
% endif
% if enrollment.mode != "verified":
% if is_paid_course and show_refund_option:
## Translators: The course's name will be added to the end of this sentence.
<a
href=
"#unenroll-modal"
class=
"unenroll"
rel=
"leanModal"
data-course-id=
"${course.id.to_deprecated_string()}"
data-course-number=
"${course.number}"
onclick=
"document.getElementById('track-info').innerHTML='${_("
Are
you
sure
you
want
to
unregister
from
the
purchased
course
")}';
document
.
getElementById
('
refund-info
').
innerHTML=
gettext('You
will
be
refunded
the
amount
you
paid
.')"
>
${_('Unregister')}
</a>
% elif is_paid_course and not show_refund_option:
## Translators: The course's name will be added to the end of this sentence.
<a
href=
"#unenroll-modal"
class=
"unenroll"
rel=
"leanModal"
data-course-id=
"${course.id.to_deprecated_string()}"
data-course-number=
"${course.number}"
onclick=
"document.getElementById('track-info').innerHTML='${_("
Are
you
sure
you
want
to
unregister
from
the
purchased
course
")}';
document
.
getElementById
('
refund-info
').
innerHTML=
gettext('You
will
not
be
refunded
the
amount
you
paid
.')"
>
${_('Unregister')}
</a>
% elif enrollment.mode != "verified":
## Translators: The course's name will be added to the end of this sentence.
<a
href=
"#unenroll-modal"
class=
"unenroll"
rel=
"leanModal"
data-course-id=
"${course.id.to_deprecated_string()}"
data-course-number=
"${course.number}"
onclick=
"document.getElementById('track-info').innerHTML='${_("
Are
you
sure
you
want
to
unregister
from
")}';
document
.
getElementById
('
refund-info
').
innerHTML=
''
"
>
${_('Unregister')}
...
...
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