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
4781467c
Commit
4781467c
authored
Jul 24, 2015
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Fulfillment of No-ID Professional Enrollments
parent
35e5ea8a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
14 deletions
+46
-14
ecommerce/courses/publishers.py
+3
-7
ecommerce/courses/tests/test_utils.py
+26
-0
ecommerce/courses/utils.py
+8
-0
ecommerce/extensions/fulfillment/modules.py
+4
-3
ecommerce/extensions/fulfillment/tests/test_modules.py
+5
-4
No files found.
ecommerce/courses/publishers.py
View file @
4781467c
...
@@ -4,16 +4,12 @@ import logging
...
@@ -4,16 +4,12 @@ import logging
from
django.conf
import
settings
from
django.conf
import
settings
import
requests
import
requests
from
ecommerce.courses.utils
import
mode_for_seat
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
LMSPublisher
(
object
):
class
LMSPublisher
(
object
):
# TODO Test this and update SKU generation
def
mode_for_seat
(
self
,
seat
):
if
seat
.
attr
.
certificate_type
==
'professional'
and
not
seat
.
attr
.
id_verification_required
:
return
'no-id-professional'
return
seat
.
attr
.
certificate_type
def
get_seat_expiration
(
self
,
seat
):
def
get_seat_expiration
(
self
,
seat
):
if
not
seat
.
expires
or
'professional'
in
seat
.
attr
.
certificate_type
:
if
not
seat
.
expires
or
'professional'
in
seat
.
attr
.
certificate_type
:
return
None
return
None
...
@@ -24,7 +20,7 @@ class LMSPublisher(object):
...
@@ -24,7 +20,7 @@ class LMSPublisher(object):
""" Serializes a course seat product to a dict that can be further serialized to JSON. """
""" Serializes a course seat product to a dict that can be further serialized to JSON. """
stock_record
=
seat
.
stockrecords
.
first
()
stock_record
=
seat
.
stockrecords
.
first
()
return
{
return
{
'name'
:
self
.
mode_for_seat
(
seat
),
'name'
:
mode_for_seat
(
seat
),
'currency'
:
stock_record
.
price_currency
,
'currency'
:
stock_record
.
price_currency
,
'price'
:
int
(
stock_record
.
price_excl_tax
),
'price'
:
int
(
stock_record
.
price_excl_tax
),
'sku'
:
stock_record
.
partner_sku
,
'sku'
:
stock_record
.
partner_sku
,
...
...
ecommerce/courses/tests/test_utils.py
0 → 100644
View file @
4781467c
import
ddt
from
django.test
import
TestCase
from
ecommerce.courses.models
import
Course
from
ecommerce.courses.utils
import
mode_for_seat
from
ecommerce.extensions.catalogue.tests.mixins
import
CourseCatalogTestMixin
@ddt.ddt
class
UtilsTests
(
CourseCatalogTestMixin
,
TestCase
):
@ddt.unpack
@ddt.data
(
(
'honor'
,
True
,
'honor'
),
(
'honor'
,
False
,
'honor'
),
(
'verified'
,
True
,
'verified'
),
(
'verified'
,
False
,
'verified'
),
(
'professional'
,
True
,
'professional'
),
(
'professional'
,
False
,
'no-id-professional'
),
(
'no-id-professional'
,
False
,
'no-id-professional'
),
)
def
test_mode_for_seat
(
self
,
certificate_type
,
id_verification_required
,
mode
):
""" Verify the correct enrollment mode is returned for a given seat. """
course
=
Course
.
objects
.
create
(
id
=
'edx/Demo_Course/DemoX'
)
seat
=
course
.
create_or_update_seat
(
certificate_type
,
id_verification_required
,
10.00
)
self
.
assertEqual
(
mode_for_seat
(
seat
),
mode
)
ecommerce/courses/utils.py
0 → 100644
View file @
4781467c
def
mode_for_seat
(
seat
):
""" Returns the Enrollment mode for a given seat product. """
certificate_type
=
seat
.
attr
.
certificate_type
if
certificate_type
==
'professional'
and
not
seat
.
attr
.
id_verification_required
:
return
'no-id-professional'
return
certificate_type
ecommerce/extensions/fulfillment/modules.py
View file @
4781467c
...
@@ -11,6 +11,7 @@ from django.conf import settings
...
@@ -11,6 +11,7 @@ from django.conf import settings
from
rest_framework
import
status
from
rest_framework
import
status
import
requests
import
requests
from
requests.exceptions
import
ConnectionError
,
Timeout
from
requests.exceptions
import
ConnectionError
,
Timeout
from
ecommerce.courses.utils
import
mode_for_seat
from
ecommerce.extensions.analytics.utils
import
audit_log
from
ecommerce.extensions.analytics.utils
import
audit_log
from
ecommerce.extensions.fulfillment.status
import
LINE
from
ecommerce.extensions.fulfillment.status
import
LINE
...
@@ -153,7 +154,7 @@ class EnrollmentFulfillmentModule(BaseFulfillmentModule):
...
@@ -153,7 +154,7 @@ class EnrollmentFulfillmentModule(BaseFulfillmentModule):
for
line
in
lines
:
for
line
in
lines
:
try
:
try
:
certificate_type
=
line
.
product
.
attr
.
certificate_type
mode
=
mode_for_seat
(
line
.
product
)
course_key
=
line
.
product
.
attr
.
course_key
course_key
=
line
.
product
.
attr
.
course_key
except
AttributeError
:
except
AttributeError
:
logger
.
error
(
"Supported Seat Product does not have required attributes, [certificate_type, course_key]"
)
logger
.
error
(
"Supported Seat Product does not have required attributes, [certificate_type, course_key]"
)
...
@@ -168,7 +169,7 @@ class EnrollmentFulfillmentModule(BaseFulfillmentModule):
...
@@ -168,7 +169,7 @@ class EnrollmentFulfillmentModule(BaseFulfillmentModule):
data
=
{
data
=
{
'user'
:
order
.
user
.
username
,
'user'
:
order
.
user
.
username
,
'is_active'
:
True
,
'is_active'
:
True
,
'mode'
:
certificate_typ
e
,
'mode'
:
mod
e
,
'course_details'
:
{
'course_details'
:
{
'course_id'
:
course_key
'course_id'
:
course_key
},
},
...
@@ -194,7 +195,7 @@ class EnrollmentFulfillmentModule(BaseFulfillmentModule):
...
@@ -194,7 +195,7 @@ class EnrollmentFulfillmentModule(BaseFulfillmentModule):
order_number
=
order
.
number
,
order_number
=
order
.
number
,
product_class
=
line
.
product
.
get_product_class
()
.
name
,
product_class
=
line
.
product
.
get_product_class
()
.
name
,
course_id
=
course_key
,
course_id
=
course_key
,
certificate_type
=
certificate_typ
e
,
mode
=
mod
e
,
user_id
=
order
.
user
.
id
,
user_id
=
order
.
user
.
id
,
credit_provider
=
provider
,
credit_provider
=
provider
,
)
)
...
...
ecommerce/extensions/fulfillment/tests/test_modules.py
View file @
4781467c
...
@@ -14,6 +14,7 @@ from requests.exceptions import ConnectionError, Timeout
...
@@ -14,6 +14,7 @@ from requests.exceptions import ConnectionError, Timeout
from
testfixtures
import
LogCapture
from
testfixtures
import
LogCapture
from
ecommerce.courses.models
import
Course
from
ecommerce.courses.models
import
Course
from
ecommerce.courses.utils
import
mode_for_seat
from
ecommerce.extensions.catalogue.tests.mixins
import
CourseCatalogTestMixin
from
ecommerce.extensions.catalogue.tests.mixins
import
CourseCatalogTestMixin
from
ecommerce.extensions.fulfillment.modules
import
EnrollmentFulfillmentModule
from
ecommerce.extensions.fulfillment.modules
import
EnrollmentFulfillmentModule
from
ecommerce.extensions.fulfillment.status
import
LINE
from
ecommerce.extensions.fulfillment.status
import
LINE
...
@@ -66,11 +67,11 @@ class EnrollmentFulfillmentModuleTests(EnrollmentFulfillmentTestMixin, TestCase)
...
@@ -66,11 +67,11 @@ class EnrollmentFulfillmentModuleTests(EnrollmentFulfillmentTestMixin, TestCase)
(
(
LOGGER_NAME
,
LOGGER_NAME
,
'INFO'
,
'INFO'
,
'line_fulfilled: c
ertificate_type="{}", course_id="{}", credit_provider
="{}", order_line_id="{}", '
'line_fulfilled: c
ourse_id="{}", credit_provider="{}", mode
="{}", order_line_id="{}", '
'order_number="{}", product_class="{}", user_id="{}"'
.
format
(
'order_number="{}", product_class="{}", user_id="{}"'
.
format
(
line
.
product
.
attr
.
certificate_type
,
line
.
product
.
attr
.
course_key
,
line
.
product
.
attr
.
course_key
,
None
,
None
,
mode_for_seat
(
line
.
product
),
line
.
id
,
line
.
id
,
line
.
order
.
number
,
line
.
order
.
number
,
line
.
product
.
get_product_class
()
.
name
,
line
.
product
.
get_product_class
()
.
name
,
...
@@ -240,11 +241,11 @@ class EnrollmentFulfillmentCreditSeatModuleTests(EnrollmentFulfillmentTestMixin,
...
@@ -240,11 +241,11 @@ class EnrollmentFulfillmentCreditSeatModuleTests(EnrollmentFulfillmentTestMixin,
(
(
LOGGER_NAME
,
LOGGER_NAME
,
'INFO'
,
'INFO'
,
'line_fulfilled: c
ertificate_type="{}", course_id="{}", credit_provider
="{}", order_line_id="{}", '
'line_fulfilled: c
ourse_id="{}", credit_provider="{}", mode
="{}", order_line_id="{}", '
'order_number="{}", product_class="{}", user_id="{}"'
.
format
(
'order_number="{}", product_class="{}", user_id="{}"'
.
format
(
line
.
product
.
attr
.
certificate_type
,
line
.
product
.
attr
.
course_key
,
line
.
product
.
attr
.
course_key
,
line
.
product
.
attr
.
credit_provider
,
line
.
product
.
attr
.
credit_provider
,
mode_for_seat
(
line
.
product
),
line
.
id
,
line
.
id
,
line
.
order
.
number
,
line
.
order
.
number
,
line
.
product
.
get_product_class
()
.
name
,
line
.
product
.
get_product_class
()
.
name
,
...
...
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