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
83e557dc
Commit
83e557dc
authored
May 15, 2016
by
Jacek Bzdak
Committed by
E. Kolpakov
Aug 31, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When Proffesional course was created without verification don't
verify the user.
parent
5c01e745
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
255 additions
and
94 deletions
+255
-94
lms/static/js/commerce/views/receipt_view.js
+27
-5
lms/static/js/spec/commerce/receipt_view_spec.js
+228
-89
No files found.
lms/static/js/commerce/views/receipt_view.js
View file @
83e557dc
...
@@ -24,15 +24,37 @@ var edx = edx || {};
...
@@ -24,15 +24,37 @@ var edx = edx || {};
this
.
render
();
this
.
render
();
},
},
renderReceipt
:
function
(
data
)
{
/**
var
templateHtml
=
$
(
"#receipt-tpl"
).
html
(),
* @param product
* @returns {bool} True if product requires user to be verified by Software Secure.
*/
requiresVerification
:
function
(
product
)
{
function
getAttribute
(
attribute
,
defaultValue
)
{
var
attr
=
_
.
findWhere
(
product
.
attribute_values
,
{
name
:
attribute
});
if
(
!
attr
)
{
return
defaultValue
;
}
return
attr
.
value
;
}
return
getAttribute
(
'id_verification_required'
,
true
);
},
renderReceipt
:
function
(
data
)
{
var
templateHtml
=
$
(
'#receipt-tpl'
).
html
(),
self
=
this
,
self
=
this
,
context
=
{
context
=
{
platformName
:
this
.
$el
.
data
(
'platform-name'
),
platformName
:
this
.
$el
.
data
(
'platform-name'
),
verified
:
this
.
$el
.
data
(
'verified'
).
toLowerCase
()
===
'true'
,
verified
:
this
.
$el
.
data
(
'verified'
).
toLowerCase
()
===
'true'
,
is_request_in_themed_site
:
this
.
$el
.
data
(
'is-request-in-themed-site'
).
toLowerCase
()
===
'true'
is_request_in_themed_site
:
this
.
$el
.
data
(
'is-request-in-themed-site'
).
toLowerCase
()
===
'true'
},
},
providerId
;
providerId
,
courseRequiresVerification
;
// True if any of the courses bought requires verification
courseRequiresVerification
=
_
.
any
(
data
.
lines
,
function
(
line
)
{
return
this
.
requiresVerification
(
line
.
product
);
},
this
);
// Add the receipt info to the template context
// Add the receipt info to the template context
this
.
courseKey
=
this
.
getOrderCourseKey
(
data
);
this
.
courseKey
=
this
.
getOrderCourseKey
(
data
);
...
@@ -45,7 +67,7 @@ var edx = edx || {};
...
@@ -45,7 +67,7 @@ var edx = edx || {};
_
.
extend
(
context
,
{
_
.
extend
(
context
,
{
receipt
:
self
.
receiptContext
(
data
),
receipt
:
self
.
receiptContext
(
data
),
courseKey
:
self
.
courseKey
,
courseKey
:
self
.
courseKey
,
is_verification_required
:
response
.
is_verification_required
is_verification_required
:
response
.
is_verification_required
&&
courseRequiresVerification
});
});
self
.
$el
.
html
(
_
.
template
(
templateHtml
)(
context
));
self
.
$el
.
html
(
_
.
template
(
templateHtml
)(
context
));
...
@@ -331,7 +353,7 @@ var edx = edx || {};
...
@@ -331,7 +353,7 @@ var edx = edx || {};
new
edx
.
commerce
.
ReceiptView
({
new
edx
.
commerce
.
ReceiptView
({
el
:
$
(
'#receipt-container'
)
el
:
$
(
'#receipt-container'
)
});
});
}
)(
jQuery
,
_
,
Backbone
);
}
(
jQuery
,
_
,
Backbone
)
);
function
completeOrder
(
event
)
{
function
completeOrder
(
event
)
{
'use strict'
;
'use strict'
;
...
...
lms/static/js/spec/commerce/receipt_view_spec.js
View file @
83e557dc
...
@@ -8,6 +8,7 @@ define([
...
@@ -8,6 +8,7 @@ define([
'use strict'
;
'use strict'
;
describe
(
'edx.commerce.ReceiptView'
,
function
()
{
describe
(
'edx.commerce.ReceiptView'
,
function
()
{
var
data
,
courseResponseData
,
providerResponseData
,
mockRequests
,
mockRender
,
createReceiptView
,
var
data
,
courseResponseData
,
providerResponseData
,
mockRequests
,
mockRender
,
createReceiptView
,
createProduct
,
createLine
,
createOrderResponse
,
doCheckVerification
,
doCheckVerificationNagRendered
,
userResponseData
;
userResponseData
;
createReceiptView
=
function
()
{
createReceiptView
=
function
()
{
...
@@ -19,17 +20,23 @@ define([
...
@@ -19,17 +20,23 @@ define([
AjaxHelpers
.
respondWithJson
(
requests
,
responseData
);
AjaxHelpers
.
respondWithJson
(
requests
,
responseData
);
};
};
mockRender
=
function
(
useEcommerceOrderNumber
,
isVerified
)
{
mockRender
=
function
(
useEcommerceOrderNumber
,
isVerified
,
requestInThemedSite
)
{
var
requests
,
view
,
orderUrlFormat
;
var
requests
,
view
,
orderUrlFormat
,
actualRequestInThemedSite
=
requestInThemedSite
;
if
(
typeof
actualRequestInThemedSite
===
'undefined'
)
{
actualRequestInThemedSite
=
'False'
;
}
requests
=
AjaxHelpers
.
requests
(
this
);
requests
=
AjaxHelpers
.
requests
(
this
);
$
(
'#receipt-container'
).
data
(
'verified'
,
isVerified
);
$
(
'#receipt-container'
).
data
({
verified
:
isVerified
,
'is-request-in-themed-site'
:
actualRequestInThemedSite
});
view
=
createReceiptView
();
view
=
createReceiptView
();
view
.
useEcommerceApi
=
true
;
view
.
useEcommerceApi
=
true
;
if
(
useEcommerceOrderNumber
)
{
if
(
useEcommerceOrderNumber
)
{
view
.
ecommerceOrderNumber
=
'EDX-123456'
;
view
.
ecommerceOrderNumber
=
'EDX-123456'
;
orderUrlFormat
=
'/api/commerce/v1/orders/EDX-123456/'
;
orderUrlFormat
=
'/api/commerce/v1/orders/EDX-123456/'
;
}
}
else
{
else
{
view
.
ecommerceBasketId
=
'EDX-123456'
;
view
.
ecommerceBasketId
=
'EDX-123456'
;
orderUrlFormat
=
'/api/commerce/v0/baskets/EDX-123456/order/'
;
orderUrlFormat
=
'/api/commerce/v0/baskets/EDX-123456/order/'
;
}
}
...
@@ -53,6 +60,107 @@ define([
...
@@ -53,6 +60,107 @@ define([
return
view
;
return
view
;
};
};
createProduct
=
function
(
attributes
)
{
var
actualAttributes
=
attributes
;
if
(
typeof
actualAttributes
===
'undefined'
)
{
actualAttributes
=
[
{
name
:
'certificate_type'
,
value
:
'verified'
},
{
name
:
'course_key'
,
code
:
'course_key'
,
value
:
'course-v1:edx+dummy+2015_T3'
},
{
name
:
'credit_provider'
,
value
:
'edx'
}
];
}
return
{
attribute_values
:
actualAttributes
,
stockrecords
:
[
{
price_currency
:
'USD'
,
product
:
123
,
partner_sku
:
'1234ABC'
,
partner
:
1
,
price_excl_tax
:
'10.00'
,
id
:
123
}
],
product_class
:
'Seat'
,
title
:
'Dummy title'
,
url
:
'https://ecom.edx.org/api/v2/products/123/'
,
price
:
'10.00'
,
expires
:
null
,
is_available_to_buy
:
true
,
id
:
123
,
structure
:
'child'
};
};
createLine
=
function
(
product
)
{
var
actualProduct
=
product
;
if
(
typeof
actualProduct
===
'undefined'
)
{
actualProduct
=
createProduct
();
}
return
{
status
:
'Open'
,
unit_price_excl_tax
:
'10.00'
,
product
:
actualProduct
,
line_price_excl_tax
:
'10.00'
,
description
:
'dummy description'
,
title
:
'dummy title'
,
quantity
:
1
};
};
createOrderResponse
=
function
(
lines
)
{
var
actualLines
=
lines
;
if
(
typeof
actualLines
===
'undefined'
)
{
actualLines
=
[
createLine
()];
}
return
{
status
:
'Open'
,
billed_to
:
{
city
:
'dummy city'
,
first_name
:
'john'
,
last_name
:
'doe'
,
country
:
'AL'
,
line2
:
'line2'
,
line1
:
'line1'
,
state
:
''
,
postcode
:
'12345'
},
lines
:
actualLines
,
number
:
'EDX-123456'
,
date_placed
:
'2016-01-01T01:01:01Z'
,
currency
:
'USD'
,
total_excl_tax
:
'10.00'
};
};
doCheckVerification
=
function
(
attributes
,
expected
)
{
var
view
=
createReceiptView
(),
product
=
createProduct
(
attributes
);
expect
(
view
.
requiresVerification
(
product
)).
toBe
(
expected
);
};
doCheckVerificationNagRendered
=
function
(
attributes
,
userVerified
,
expected
,
requestInThemedSite
)
{
var
view
;
data
=
createOrderResponse
([
createLine
(
createProduct
(
attributes
))]);
view
=
mockRender
(
true
,
userVerified
,
requestInThemedSite
);
if
(
expected
)
{
expect
(
view
.
$
(
'.nav-wizard.is-ready'
).
text
()).
toContain
(
'Want to confirm your identity later'
);
}
else
{
expect
(
view
.
$
(
'.nav-wizard.is-ready'
).
text
()).
toContain
(
'Go to Dashboard'
);
}
};
beforeEach
(
function
()
{
beforeEach
(
function
()
{
var
receiptFixture
,
providerFixture
;
var
receiptFixture
,
providerFixture
;
// Stub analytics tracking
// Stub analytics tracking
...
@@ -63,97 +171,38 @@ define([
...
@@ -63,97 +171,38 @@ define([
receiptFixture
=
readFixtures
(
'templates/commerce/receipt.underscore'
);
receiptFixture
=
readFixtures
(
'templates/commerce/receipt.underscore'
);
providerFixture
=
readFixtures
(
'templates/commerce/provider.underscore'
);
providerFixture
=
readFixtures
(
'templates/commerce/provider.underscore'
);
appendSetFixtures
(
appendSetFixtures
(
'<script id=
\
"receipt-tpl
\
" type=
\
"text/template
\
" >'
+
receiptFixture
+
'</script>'
+
'<script id=
"receipt-tpl" type="text/template
" >'
+
receiptFixture
+
'</script>'
+
'<script id=
\
"provider-tpl
\
" type=
\
"text/template
\
" >'
+
providerFixture
+
'</script>'
'<script id=
"provider-tpl" type="text/template
" >'
+
providerFixture
+
'</script>'
);
);
data
=
{
data
=
createOrderResponse
();
'status'
:
'Open'
,
'billed_to'
:
{
'city'
:
'dummy city'
,
'first_name'
:
'john'
,
'last_name'
:
'doe'
,
'country'
:
'AL'
,
'line2'
:
'line2'
,
'line1'
:
'line1'
,
'state'
:
''
,
'postcode'
:
'12345'
},
'lines'
:
[
{
'status'
:
'Open'
,
'unit_price_excl_tax'
:
'10.00'
,
'product'
:
{
'attribute_values'
:
[
{
'name'
:
'certificate_type'
,
'value'
:
'verified'
},
{
'name'
:
'course_key'
,
'code'
:
'course_key'
,
'value'
:
'course-v1:edx+dummy+2015_T3'
},
{
'name'
:
'credit_provider'
,
'value'
:
'edx'
}
],
'stockrecords'
:
[
{
'price_currency'
:
'USD'
,
'product'
:
123
,
'partner_sku'
:
'1234ABC'
,
'partner'
:
1
,
'price_excl_tax'
:
'10.00'
,
'id'
:
123
}
],
'product_class'
:
'Seat'
,
'title'
:
'Dummy title'
,
'url'
:
'https://ecom.edx.org/api/v2/products/123/'
,
'price'
:
'10.00'
,
'expires'
:
null
,
'is_available_to_buy'
:
true
,
'id'
:
123
,
'structure'
:
'child'
},
'line_price_excl_tax'
:
'10.00'
,
'description'
:
'dummy description'
,
'title'
:
'dummy title'
,
'quantity'
:
1
}
],
'number'
:
'EDX-123456'
,
'date_placed'
:
'2016-01-01T01:01:01Z'
,
'currency'
:
'USD'
,
'total_excl_tax'
:
'10.00'
};
providerResponseData
=
{
providerResponseData
=
{
'id'
:
'edx'
,
id
:
'edx'
,
'display_name'
:
'edX'
,
display_name
:
'edX'
,
'url'
:
'http://www.edx.org'
,
url
:
'http://www.edx.org'
,
'status_url'
:
'http://www.edx.org/status'
,
status_url
:
'http://www.edx.org/status'
,
'description'
:
'Nothing'
,
description
:
'Nothing'
,
'enable_integration'
:
false
,
enable_integration
:
false
,
'fulfillment_instructions'
:
''
,
fulfillment_instructions
:
''
,
'thumbnail_url'
:
'http://edx.org/thumbnail.png'
thumbnail_url
:
'http://edx.org/thumbnail.png'
};
};
courseResponseData
=
{
courseResponseData
=
{
'id'
:
'course-v1:edx+dummy+2015_T3'
,
id
:
'course-v1:edx+dummy+2015_T3'
,
'name'
:
'receipt test'
,
name
:
'receipt test'
,
'category'
:
'course'
,
category
:
'course'
,
'org'
:
'edx'
,
org
:
'edx'
,
'run'
:
'2015_T2'
,
run
:
'2015_T2'
,
'course'
:
'CS420'
,
course
:
'CS420'
,
'uri'
:
'http://test.com/api/courses/v1/courses/course-v1:edx+dummy+2015_T3/'
,
uri
:
'http://test.com/api/courses/v1/courses/course-v1:edx+dummy+2015_T3/'
,
'image_url'
:
'/test.jpg'
,
image_url
:
'/test.jpg'
,
'start'
:
'2030-01-01T00:00:00Z'
,
start
:
'2030-01-01T00:00:00Z'
,
'end'
:
null
end
:
null
};
};
userResponseData
=
{
userResponseData
=
{
'username'
:
'user-1'
,
username
:
'user-1'
,
'name'
:
'full name'
name
:
'full name'
};
};
});
});
...
@@ -194,6 +243,96 @@ define([
...
@@ -194,6 +243,96 @@ define([
view
=
mockRender
(
false
,
'True'
);
view
=
mockRender
(
false
,
'True'
);
expect
(
view
.
$
(
'.course_name_placeholder'
).
text
()).
toContain
(
'receipt test'
);
expect
(
view
.
$
(
'.course_name_placeholder'
).
text
()).
toContain
(
'receipt test'
);
});
});
it
(
'requiresVerification returns true if product requires verification'
,
function
()
{
var
expected
=
true
,
attributes
=
[
{
name
:
'certificate_type'
,
value
:
'professional'
},
{
name
:
'course_key'
,
value
:
'course-v1:OC+OC+2'
},
{
name
:
'id_verification_required'
,
value
:
true
}
];
doCheckVerification
(
attributes
,
expected
,
'False'
);
});
it
(
'requiresVerification returns true if product requires verification, different order'
,
function
()
{
var
expected
=
true
,
attributes
=
[
{
name
:
'certificate_type'
,
value
:
'professional'
},
{
name
:
'id_verification_required'
,
value
:
true
},
{
name
:
'course_key'
,
value
:
'course-v1:OC+OC+2'
}
];
doCheckVerification
(
attributes
,
expected
,
'False'
);
});
it
(
'requiresVerification defaults to true'
,
function
()
{
var
expected
=
true
,
attributes
=
[
{
name
:
'certificate_type'
,
value
:
'professional'
},
{
name
:
'course_key'
,
value
:
'course-v1:OC+OC+2'
}
];
doCheckVerification
(
attributes
,
expected
,
'False'
);
});
it
(
'requiresVerification returns false for courses not requiring verification'
,
function
()
{
var
expected
=
false
,
attributes
=
[
{
name
:
'certificate_type'
,
value
:
'professional'
},
{
name
:
'id_verification_required'
,
value
:
false
},
{
name
:
'course_key'
,
value
:
'course-v1:OC+OC+2'
}
];
doCheckVerification
(
attributes
,
expected
,
'False'
);
});
it
(
'receipt view verification nag for not verified users in a verified course'
,
function
()
{
var
attributes
=
[
{
name
:
'certificate_type'
,
value
:
'professional'
},
{
name
:
'id_verification_required'
,
value
:
true
},
{
name
:
'course_key'
,
value
:
'course-v1:edx+dummy+2015_T3'
},
{
name
:
'credit_provider'
,
value
:
'edx'
}
];
doCheckVerificationNagRendered
(
attributes
,
'False'
,
true
,
'False'
);
});
it
(
"receipt view doesn't show verification nag for a verified user in a verified course"
,
function
()
{
var
attributes
=
[
{
name
:
'certificate_type'
,
value
:
'professional'
},
{
name
:
'id_verification_required'
,
value
:
true
},
{
name
:
'course_key'
,
value
:
'course-v1:edx+dummy+2015_T3'
},
{
name
:
'credit_provider'
,
value
:
'edx'
}
];
doCheckVerificationNagRendered
(
attributes
,
'True'
,
false
,
'False'
);
});
it
(
"receipt view doesn't show verification for a unverified user in a not verified course"
,
function
()
{
var
attributes
=
[
{
name
:
'certificate_type'
,
value
:
'professional'
},
{
name
:
'id_verification_required'
,
value
:
false
},
{
name
:
'course_key'
,
value
:
'course-v1:edx+dummy+2015_T3'
},
{
name
:
'credit_provider'
,
value
:
'edx'
}
];
doCheckVerificationNagRendered
(
attributes
,
'False'
,
false
,
'False'
);
});
it
(
"receipt view doesn't show verification nag for a verified user in a not verified course"
,
function
()
{
var
attributes
=
[
{
name
:
'certificate_type'
,
value
:
'professional'
},
{
name
:
'id_verification_required'
,
value
:
false
},
{
name
:
'course_key'
,
value
:
'course-v1:edx+dummy+2015_T3'
},
{
name
:
'credit_provider'
,
value
:
'edx'
}
];
doCheckVerificationNagRendered
(
attributes
,
'True'
,
false
,
'False'
);
});
it
(
"receipt view doesn't show verification nag for a not verified user in a verified"
+
' course on themed site'
,
function
()
{
var
attributes
=
[
{
name
:
'certificate_type'
,
value
:
'professional'
},
{
name
:
'id_verification_required'
,
value
:
true
},
{
name
:
'course_key'
,
value
:
'course-v1:edx+dummy+2015_T3'
},
{
name
:
'credit_provider'
,
value
:
'edx'
}
];
doCheckVerificationNagRendered
(
attributes
,
'False'
,
false
,
'True'
);
});
});
});
}
}
);
);
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