Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
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
ecommerce
Commits
51aa2cb7
Commit
51aa2cb7
authored
Jul 23, 2015
by
Awais Qureshi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #201 from edx/awais786/ECOM-1869-credit-hours
ECOM-1869 adding new attribute credit hours.
parents
c2d755a6
1eb85a23
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
6 deletions
+70
-6
ecommerce/courses/models.py
+4
-1
ecommerce/courses/tests/test_models.py
+11
-3
ecommerce/credit/tests/test_views.py
+9
-1
ecommerce/extensions/catalogue/migrations/0009_credit_hours_attr.py
+40
-0
ecommerce/extensions/catalogue/tests/mixins.py
+1
-0
ecommerce/templates/edx/credit/checkout.html
+5
-1
No files found.
ecommerce/courses/models.py
View file @
51aa2cb7
...
@@ -115,7 +115,7 @@ class Course(models.Model):
...
@@ -115,7 +115,7 @@ class Course(models.Model):
return
name
return
name
def
create_or_update_seat
(
self
,
certificate_type
,
id_verification_required
,
price
,
credit_provider
=
None
,
def
create_or_update_seat
(
self
,
certificate_type
,
id_verification_required
,
price
,
credit_provider
=
None
,
expires
=
None
):
expires
=
None
,
credit_hours
=
None
):
"""
"""
Creates course seat products.
Creates course seat products.
...
@@ -152,6 +152,9 @@ class Course(models.Model):
...
@@ -152,6 +152,9 @@ class Course(models.Model):
if
credit_provider
:
if
credit_provider
:
seat
.
attr
.
credit_provider
=
credit_provider
seat
.
attr
.
credit_provider
=
credit_provider
if
credit_hours
:
seat
.
attr
.
credit_hours
=
credit_hours
seat
.
save
()
seat
.
save
()
# TODO Expose via setting
# TODO Expose via setting
...
...
ecommerce/courses/tests/test_models.py
View file @
51aa2cb7
...
@@ -138,7 +138,7 @@ class CourseTests(CourseCatalogTestMixin, TestCase):
...
@@ -138,7 +138,7 @@ class CourseTests(CourseCatalogTestMixin, TestCase):
self
.
assertEqual
(
parent
.
attr
.
course_key
,
course
.
id
)
self
.
assertEqual
(
parent
.
attr
.
course_key
,
course
.
id
)
def
assert_course_seat_valid
(
self
,
seat
,
course
,
certificate_type
,
id_verification_required
,
price
,
def
assert_course_seat_valid
(
self
,
seat
,
course
,
certificate_type
,
id_verification_required
,
price
,
credit_provider
=
None
):
credit_provider
=
None
,
credit_hours
=
None
):
""" Ensure the given seat has the correct attribute values. """
""" Ensure the given seat has the correct attribute values. """
self
.
assertEqual
(
seat
.
structure
,
Product
.
CHILD
)
self
.
assertEqual
(
seat
.
structure
,
Product
.
CHILD
)
# pylint: disable=protected-access
# pylint: disable=protected-access
...
@@ -152,6 +152,9 @@ class CourseTests(CourseCatalogTestMixin, TestCase):
...
@@ -152,6 +152,9 @@ class CourseTests(CourseCatalogTestMixin, TestCase):
if
credit_provider
:
if
credit_provider
:
self
.
assertEqual
(
seat
.
attr
.
credit_provider
,
credit_provider
)
self
.
assertEqual
(
seat
.
attr
.
credit_provider
,
credit_provider
)
if
credit_hours
:
self
.
assertEqual
(
seat
.
attr
.
credit_hours
,
credit_hours
)
def
test_create_or_update_seat
(
self
):
def
test_create_or_update_seat
(
self
):
""" Verify the method creates or updates a seat Product. """
""" Verify the method creates or updates a seat Product. """
course
=
Course
.
objects
.
create
(
id
=
'a/b/c'
,
name
=
'Test Course'
)
course
=
Course
.
objects
.
create
(
id
=
'a/b/c'
,
name
=
'Test Course'
)
...
@@ -170,12 +173,17 @@ class CourseTests(CourseCatalogTestMixin, TestCase):
...
@@ -170,12 +173,17 @@ class CourseTests(CourseCatalogTestMixin, TestCase):
# Test update
# Test update
price
=
100
price
=
100
credit_provider
=
'MIT'
credit_provider
=
'MIT'
course
.
create_or_update_seat
(
certificate_type
,
id_verification_required
,
price
,
credit_provider
)
credit_hours
=
2
course
.
create_or_update_seat
(
certificate_type
,
id_verification_required
,
price
,
credit_provider
,
credit_hours
=
credit_hours
)
# Again, only two seats with one being the parent seat product.
# Again, only two seats with one being the parent seat product.
self
.
assertEqual
(
course
.
products
.
count
(),
2
)
self
.
assertEqual
(
course
.
products
.
count
(),
2
)
seat
=
course
.
seat_products
[
0
]
seat
=
course
.
seat_products
[
0
]
self
.
assert_course_seat_valid
(
seat
,
course
,
certificate_type
,
id_verification_required
,
price
,
credit_provider
)
self
.
assert_course_seat_valid
(
seat
,
course
,
certificate_type
,
id_verification_required
,
price
,
credit_provider
,
credit_hours
=
credit_hours
)
def
test_type
(
self
):
def
test_type
(
self
):
""" Verify the property returns a type value corresponding to the available products. """
""" Verify the property returns a type value corresponding to the available products. """
...
...
ecommerce/credit/tests/test_views.py
View file @
51aa2cb7
...
@@ -27,6 +27,7 @@ class CheckoutPageTest(UserMixin, CourseCatalogTestMixin, TestCase):
...
@@ -27,6 +27,7 @@ class CheckoutPageTest(UserMixin, CourseCatalogTestMixin, TestCase):
self
.
provider
=
'ASU'
self
.
provider
=
'ASU'
self
.
price
=
100
self
.
price
=
100
self
.
thumbnail_url
=
'http://www.edx.org/course.jpg'
self
.
thumbnail_url
=
'http://www.edx.org/course.jpg'
self
.
credit_hours
=
2
# Create the course
# Create the course
self
.
course
=
Course
.
objects
.
create
(
self
.
course
=
Course
.
objects
.
create
(
id
=
u'edx/Demo_Course/DemoX'
,
id
=
u'edx/Demo_Course/DemoX'
,
...
@@ -35,7 +36,9 @@ class CheckoutPageTest(UserMixin, CourseCatalogTestMixin, TestCase):
...
@@ -35,7 +36,9 @@ class CheckoutPageTest(UserMixin, CourseCatalogTestMixin, TestCase):
)
)
# Create the credit seat
# Create the credit seat
self
.
seat
=
self
.
course
.
create_or_update_seat
(
'credit'
,
True
,
self
.
price
,
self
.
provider
)
self
.
seat
=
self
.
course
.
create_or_update_seat
(
'credit'
,
True
,
self
.
price
,
self
.
provider
,
credit_hours
=
self
.
credit_hours
)
@property
@property
def
path
(
self
):
def
path
(
self
):
...
@@ -74,3 +77,8 @@ class CheckoutPageTest(UserMixin, CourseCatalogTestMixin, TestCase):
...
@@ -74,3 +77,8 @@ class CheckoutPageTest(UserMixin, CourseCatalogTestMixin, TestCase):
# Verify the payment processors are returned
# Verify the payment processors are returned
self
.
assertEqual
(
sorted
(
response
.
context
[
'payment_processors'
]
.
keys
()),
self
.
assertEqual
(
sorted
(
response
.
context
[
'payment_processors'
]
.
keys
()),
sorted
([
get_processor_class
(
path
)
.
NAME
.
lower
()
for
path
in
settings
.
PAYMENT_PROCESSORS
]))
sorted
([
get_processor_class
(
path
)
.
NAME
.
lower
()
for
path
in
settings
.
PAYMENT_PROCESSORS
]))
self
.
assertContains
(
response
,
'You are purchasing {} credit hours for'
.
format
(
self
.
credit_hours
)
)
ecommerce/extensions/catalogue/migrations/0009_credit_hours_attr.py
0 → 100644
View file @
51aa2cb7
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
def
create_credit_hours_attribute
(
apps
,
schema_editor
):
# Get seat Object
ProductClass
=
apps
.
get_model
(
'catalogue'
,
'ProductClass'
)
seat
=
ProductClass
.
objects
.
get
(
name
=
'Seat'
)
# Create our Product Attributes
ProductAttribute
=
apps
.
get_model
(
'catalogue'
,
'ProductAttribute'
)
ProductAttribute
.
objects
.
create
(
product_class
=
seat
,
name
=
'credit_hours'
,
code
=
'credit_hours'
,
type
=
'integer'
,
required
=
False
)
def
delete_credit_hours_attribute
(
apps
,
schema_editor
):
"""For backward compatibility"""
# Delete our Product Attributes
ProductAttribute
=
apps
.
get_model
(
'catalogue'
,
'ProductAttribute'
)
ProductAttribute
.
objects
.
filter
(
code
=
'credit_hours'
)
.
delete
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'catalogue'
,
'0008_auto_20150709_1254'
),
]
operations
=
[
migrations
.
RunPython
(
create_credit_hours_attribute
,
delete_credit_hours_attribute
),
]
ecommerce/extensions/catalogue/tests/mixins.py
View file @
51aa2cb7
...
@@ -37,6 +37,7 @@ class CourseCatalogTestMixin(object):
...
@@ -37,6 +37,7 @@ class CourseCatalogTestMixin(object):
(
'course_key'
,
'text'
),
(
'course_key'
,
'text'
),
(
'credit_provider'
,
'text'
),
(
'credit_provider'
,
'text'
),
(
'id_verification_required'
,
'boolean'
),
(
'id_verification_required'
,
'boolean'
),
(
'credit_hours'
,
'integer'
),
)
)
for
code
,
attr_type
in
attributes
:
for
code
,
attr_type
in
attributes
:
...
...
ecommerce/templates/edx/credit/checkout.html
View file @
51aa2cb7
...
@@ -12,7 +12,11 @@
...
@@ -12,7 +12,11 @@
</div>
</div>
<div
class=
"col-sm-9"
>
<div
class=
"col-sm-9"
>
<h3
class=
"title"
>
<h3
class=
"title"
>
Purchasing credit for:
{% blocktrans count hours=credit_seats.0.attr.credit_hours %}
You are purchasing 1 credit hour for:
{% plural %}
You are purchasing {{ hours }} credit hours for:
{% endblocktrans %}
<span
class=
"course-title text-nowrap"
>
{{ course.name }}
</span>
<span
class=
"course-title text-nowrap"
>
{{ course.name }}
</span>
</h3>
</h3>
Congratulations, you are eligible to purchase credit from {{ credit_seats.0.attr.credit_provider }} by Feb 05, 2013.
Congratulations, you are eligible to purchase credit from {{ credit_seats.0.attr.credit_provider }} by Feb 05, 2013.
...
...
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