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
42f8b970
Commit
42f8b970
authored
Aug 21, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up views and models.
parent
76766cbc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
lms/djangoapps/shoppingcart/models.py
+15
-1
lms/djangoapps/shoppingcart/views.py
+7
-2
No files found.
lms/djangoapps/shoppingcart/models.py
View file @
42f8b970
...
@@ -6,7 +6,7 @@ from django.core.exceptions import ObjectDoesNotExist
...
@@ -6,7 +6,7 @@ from django.core.exceptions import ObjectDoesNotExist
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
model_utils.managers
import
InheritanceManager
from
model_utils.managers
import
InheritanceManager
from
courseware.courses
import
course_image_url
,
get_course_about_section
from
courseware.courses
import
get_course_about_section
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.course_module
import
CourseDescriptor
...
@@ -66,6 +66,7 @@ class Order(models.Model):
...
@@ -66,6 +66,7 @@ class Order(models.Model):
@property
@property
def
total_cost
(
self
):
def
total_cost
(
self
):
""" Return the total cost of the order """
return
sum
(
i
.
line_cost
for
i
in
self
.
orderitem_set
.
filter
(
status
=
self
.
status
))
return
sum
(
i
.
line_cost
for
i
in
self
.
orderitem_set
.
filter
(
status
=
self
.
status
))
def
clear
(
self
):
def
clear
(
self
):
...
@@ -79,6 +80,19 @@ class Order(models.Model):
...
@@ -79,6 +80,19 @@ class Order(models.Model):
"""
"""
Call to mark this order as purchased. Iterates through its OrderItems and calls
Call to mark this order as purchased. Iterates through its OrderItems and calls
their purchased_callback
their purchased_callback
`first` - first name of person billed (e.g. John)
`last` - last name of person billed (e.g. Smith)
`street1` - first line of a street address of the billing address (e.g. 11 Cambridge Center)
`street2` - second line of a street address of the billing address (e.g. Suite 101)
`city` - city of the billing address (e.g. Cambridge)
`state` - code of the state, province, or territory of the billing address (e.g. MA)
`postalcode` - postal code of the billing address (e.g. 02142)
`country` - country code of the billing address (e.g. US)
`ccnum` - last 4 digits of the credit card number of the credit card billed (e.g. 1111)
`cardtype` - 3-digit code representing the card type used (e.g. 001)
`processor_reply_dump` - all the parameters returned by the processor
"""
"""
self
.
status
=
'purchased'
self
.
status
=
'purchased'
self
.
purchase_time
=
datetime
.
now
(
pytz
.
utc
)
self
.
purchase_time
=
datetime
.
now
(
pytz
.
utc
)
...
...
lms/djangoapps/shoppingcart/views.py
View file @
42f8b970
import
logging
import
logging
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
HttpResponseNotFound
,
HttpResponseForbidden
,
Http404
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
HttpResponseNotFound
,
HttpResponseForbidden
,
Http404
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.views.decorators.http
import
require_POST
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.decorators.csrf
import
csrf_exempt
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.decorators
import
login_required
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
mitxmako.shortcuts
import
render_to_response
from
mitxmako.shortcuts
import
render_to_response
from
.models
import
*
from
.models
import
Order
,
PaidCourseRegistration
,
CertificateItem
,
OrderItem
from
.processors
import
process_postpay_callback
,
render_purchase_form_html
from
.processors
import
process_postpay_callback
,
render_purchase_form_html
log
=
logging
.
getLogger
(
"shoppingcart"
)
log
=
logging
.
getLogger
(
"shoppingcart"
)
...
@@ -38,6 +39,9 @@ def add_course_to_cart(request, course_id):
...
@@ -38,6 +39,9 @@ def add_course_to_cart(request, course_id):
@login_required
@login_required
def
register_for_verified_cert
(
request
,
course_id
):
def
register_for_verified_cert
(
request
,
course_id
):
"""
Add a CertificateItem to the cart
"""
cart
=
Order
.
get_cart_for_user
(
request
.
user
)
cart
=
Order
.
get_cart_for_user
(
request
.
user
)
CertificateItem
.
add_to_order
(
cart
,
course_id
,
30
,
'verified'
)
CertificateItem
.
add_to_order
(
cart
,
course_id
,
30
,
'verified'
)
return
HttpResponse
(
"Added"
)
return
HttpResponse
(
"Added"
)
...
@@ -77,6 +81,7 @@ def remove_item(request):
...
@@ -77,6 +81,7 @@ def remove_item(request):
@csrf_exempt
@csrf_exempt
@require_POST
def
postpay_callback
(
request
):
def
postpay_callback
(
request
):
"""
"""
Receives the POST-back from processor.
Receives the POST-back from processor.
...
@@ -111,7 +116,7 @@ def show_receipt(request, ordernum):
...
@@ -111,7 +116,7 @@ def show_receipt(request, ordernum):
raise
Http404
(
'Order not found!'
)
raise
Http404
(
'Order not found!'
)
order_items
=
order
.
orderitem_set
.
all
()
order_items
=
order
.
orderitem_set
.
all
()
any_refunds
=
"refunded"
in
[
i
.
status
for
i
in
order_items
]
any_refunds
=
any
(
i
.
status
==
"refunded"
for
i
in
order_items
)
return
render_to_response
(
'shoppingcart/receipt.html'
,
{
'order'
:
order
,
return
render_to_response
(
'shoppingcart/receipt.html'
,
{
'order'
:
order
,
'order_items'
:
order_items
,
'order_items'
:
order_items
,
'any_refunds'
:
any_refunds
})
'any_refunds'
:
any_refunds
})
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