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
b8cfab0f
Commit
b8cfab0f
authored
Jul 05, 2018
by
Brittney Exline
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "ENT-1052 Rename enterprise customer catalog uuid in queryparam to catalog"
This reverts commit
58174a6f
.
parent
f436e693
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
18 deletions
+20
-18
ecommerce/enterprise/conditions.py
+13
-11
ecommerce/enterprise/tests/test_conditions.py
+3
-3
ecommerce/extensions/basket/tests/test_utils.py
+1
-1
ecommerce/extensions/basket/utils.py
+3
-3
No files found.
ecommerce/enterprise/conditions.py
View file @
b8cfab0f
...
@@ -33,7 +33,7 @@ class EnterpriseCustomerCondition(ConditionWithoutRangeMixin, SingleItemConsumpt
...
@@ -33,7 +33,7 @@ class EnterpriseCustomerCondition(ConditionWithoutRangeMixin, SingleItemConsumpt
Determines if a user is eligible for an enterprise customer offer
Determines if a user is eligible for an enterprise customer offer
based on their association with the enterprise customer.
based on their association with the enterprise customer.
It also verifies the catalog `
catalog
` on the
It also verifies the catalog `
enterprise_customer_catalog_uuid
` on the
offer with the catalog on the basket when provided.
offer with the catalog on the basket when provided.
Args:
Args:
...
@@ -74,9 +74,9 @@ class EnterpriseCustomerCondition(ConditionWithoutRangeMixin, SingleItemConsumpt
...
@@ -74,9 +74,9 @@ class EnterpriseCustomerCondition(ConditionWithoutRangeMixin, SingleItemConsumpt
# Verify that the current conditional offer is related to the provided
# Verify that the current conditional offer is related to the provided
# enterprise catalog
# enterprise catalog
catalog
=
self
.
_get_enterprise_catalog_uuid_from_basket
(
basket
)
enterprise_customer_catalog_uuid
=
self
.
_get_enterprise_catalog_uuid_from_basket
(
basket
)
if
catalog
:
if
enterprise_customer_catalog_uuid
:
if
str
(
offer
.
condition
.
enterprise_customer_catalog_uuid
)
!=
catalog
:
if
str
(
offer
.
condition
.
enterprise_customer_catalog_uuid
)
!=
enterprise_customer_catalog_uuid
:
return
False
return
False
if
not
catalog_contains_course_runs
(
basket
.
site
,
course_run_ids
,
self
.
enterprise_customer_uuid
,
if
not
catalog_contains_course_runs
(
basket
.
site
,
course_run_ids
,
self
.
enterprise_customer_uuid
,
...
@@ -96,13 +96,15 @@ class EnterpriseCustomerCondition(ConditionWithoutRangeMixin, SingleItemConsumpt
...
@@ -96,13 +96,15 @@ class EnterpriseCustomerCondition(ConditionWithoutRangeMixin, SingleItemConsumpt
basket (Basket): The provided basket can be either temporary (just
basket (Basket): The provided basket can be either temporary (just
for calculating discounts) or an actual one to buy a product.
for calculating discounts) or an actual one to buy a product.
"""
"""
# For temporary basket try to get `catalog` from request
# For temporary basket try to get `enterprise_customer_catalog_uuid`
catalog
=
basket
.
strategy
.
request
.
GET
.
get
(
# from request
'catalog'
enterprise_customer_catalog_uuid
=
basket
.
strategy
.
request
.
GET
.
get
(
'enterprise_customer_catalog_uuid'
)
if
basket
.
strategy
.
request
else
None
)
if
basket
.
strategy
.
request
else
None
if
not
catalog
:
if
not
enterprise_customer_catalog_uuid
:
# For actual baskets get `catalog` from basket attribute
# For actual baskets get `enterprise_customer_catalog_uuid` from
# basket attribute
enterprise_catalog_attribute
,
__
=
BasketAttributeType
.
objects
.
get_or_create
(
enterprise_catalog_attribute
,
__
=
BasketAttributeType
.
objects
.
get_or_create
(
name
=
ENTERPRISE_CATALOG_ATTRIBUTE_TYPE
name
=
ENTERPRISE_CATALOG_ATTRIBUTE_TYPE
)
)
...
@@ -111,6 +113,6 @@ class EnterpriseCustomerCondition(ConditionWithoutRangeMixin, SingleItemConsumpt
...
@@ -111,6 +113,6 @@ class EnterpriseCustomerCondition(ConditionWithoutRangeMixin, SingleItemConsumpt
attribute_type
=
enterprise_catalog_attribute
,
attribute_type
=
enterprise_catalog_attribute
,
)
.
first
()
)
.
first
()
if
enterprise_customer_catalog
:
if
enterprise_customer_catalog
:
catalog
=
enterprise_customer_catalog
.
value_text
enterprise_customer_catalog_uuid
=
enterprise_customer_catalog
.
value_text
return
catalog
return
enterprise_customer_catalog_uuid
ecommerce/enterprise/tests/test_conditions.py
View file @
b8cfab0f
...
@@ -78,7 +78,7 @@ class EnterpriseCustomerConditionTests(EnterpriseServiceMockMixin, DiscoveryTest
...
@@ -78,7 +78,7 @@ class EnterpriseCustomerConditionTests(EnterpriseServiceMockMixin, DiscoveryTest
enterprise_catalog_uuid
=
str
(
self
.
condition
.
enterprise_customer_catalog_uuid
)
enterprise_catalog_uuid
=
str
(
self
.
condition
.
enterprise_customer_catalog_uuid
)
basket
=
factories
.
BasketFactory
(
site
=
self
.
site
,
owner
=
self
.
user
)
basket
=
factories
.
BasketFactory
(
site
=
self
.
site
,
owner
=
self
.
user
)
basket
.
strategy
.
request
=
self
.
request
basket
.
strategy
.
request
=
self
.
request
basket
.
strategy
.
request
.
GET
=
{
'
catalog
'
:
enterprise_catalog_uuid
}
basket
.
strategy
.
request
.
GET
=
{
'
enterprise_customer_catalog_uuid
'
:
enterprise_catalog_uuid
}
self
.
_check_condition_is_satisfied
(
offer
,
basket
,
is_satisfied
=
True
)
self
.
_check_condition_is_satisfied
(
offer
,
basket
,
is_satisfied
=
True
)
@httpretty.activate
@httpretty.activate
...
@@ -89,7 +89,7 @@ class EnterpriseCustomerConditionTests(EnterpriseServiceMockMixin, DiscoveryTest
...
@@ -89,7 +89,7 @@ class EnterpriseCustomerConditionTests(EnterpriseServiceMockMixin, DiscoveryTest
offer
=
factories
.
EnterpriseOfferFactory
(
site
=
self
.
site
,
condition
=
self
.
condition
)
offer
=
factories
.
EnterpriseOfferFactory
(
site
=
self
.
site
,
condition
=
self
.
condition
)
enterprise_catalog_uuid
=
str
(
self
.
condition
.
enterprise_customer_catalog_uuid
)
enterprise_catalog_uuid
=
str
(
self
.
condition
.
enterprise_customer_catalog_uuid
)
basket
=
factories
.
BasketFactory
(
site
=
self
.
site
,
owner
=
self
.
user
)
basket
=
factories
.
BasketFactory
(
site
=
self
.
site
,
owner
=
self
.
user
)
request_data
=
{
'
catalog
'
:
enterprise_catalog_uuid
}
request_data
=
{
'
enterprise_customer_catalog_uuid
'
:
enterprise_catalog_uuid
}
basket_add_enterprise_catalog_attribute
(
basket
,
request_data
)
basket_add_enterprise_catalog_attribute
(
basket
,
request_data
)
self
.
_check_condition_is_satisfied
(
offer
,
basket
,
is_satisfied
=
True
)
self
.
_check_condition_is_satisfied
(
offer
,
basket
,
is_satisfied
=
True
)
...
@@ -103,7 +103,7 @@ class EnterpriseCustomerConditionTests(EnterpriseServiceMockMixin, DiscoveryTest
...
@@ -103,7 +103,7 @@ class EnterpriseCustomerConditionTests(EnterpriseServiceMockMixin, DiscoveryTest
invalid_enterprise_catalog_uuid
=
str
(
uuid4
())
invalid_enterprise_catalog_uuid
=
str
(
uuid4
())
basket
=
factories
.
BasketFactory
(
site
=
self
.
site
,
owner
=
self
.
user
)
basket
=
factories
.
BasketFactory
(
site
=
self
.
site
,
owner
=
self
.
user
)
basket
.
strategy
.
request
=
self
.
request
basket
.
strategy
.
request
=
self
.
request
basket
.
strategy
.
request
.
GET
=
{
'
catalog
'
:
invalid_enterprise_catalog_uuid
}
basket
.
strategy
.
request
.
GET
=
{
'
enterprise_customer_catalog_uuid
'
:
invalid_enterprise_catalog_uuid
}
self
.
_check_condition_is_satisfied
(
offer
,
basket
,
is_satisfied
=
False
)
self
.
_check_condition_is_satisfied
(
offer
,
basket
,
is_satisfied
=
False
)
assert
invalid_enterprise_catalog_uuid
!=
offer
.
condition
.
enterprise_customer_catalog_uuid
assert
invalid_enterprise_catalog_uuid
!=
offer
.
condition
.
enterprise_customer_catalog_uuid
...
...
ecommerce/extensions/basket/tests/test_utils.py
View file @
b8cfab0f
...
@@ -426,7 +426,7 @@ class BasketUtilsTests(DiscoveryTestMixin, BasketMixin, TestCase):
...
@@ -426,7 +426,7 @@ class BasketUtilsTests(DiscoveryTestMixin, BasketMixin, TestCase):
product
=
ProductFactory
()
product
=
ProductFactory
()
request
=
self
.
request
request
=
self
.
request
expected_enterprise_catalog_uuid
=
str
(
uuid4
())
expected_enterprise_catalog_uuid
=
str
(
uuid4
())
request
.
GET
=
{
'
catalog
'
:
expected_enterprise_catalog_uuid
}
request
.
GET
=
{
'
enterprise_customer_catalog_uuid
'
:
expected_enterprise_catalog_uuid
}
basket
=
prepare_basket
(
request
,
[
product
])
basket
=
prepare_basket
(
request
,
[
product
])
# Verify that the enterprise catalog attribute exists for the basket
# Verify that the enterprise catalog attribute exists for the basket
...
...
ecommerce/extensions/basket/utils.py
View file @
b8cfab0f
...
@@ -281,9 +281,9 @@ def basket_add_enterprise_catalog_attribute(basket, request_data):
...
@@ -281,9 +281,9 @@ def basket_add_enterprise_catalog_attribute(basket, request_data):
request_data (dict): HttpRequest data
request_data (dict): HttpRequest data
"""
"""
# Value of enterprise catalog UUID is being passed as
`catalog` from
# Value of enterprise catalog UUID is being passed as
# basket page
#
`enterprise_customer_catalog_uuid` from
basket page
enterprise_catalog_uuid
=
request_data
.
get
(
'
catalog
'
)
if
request_data
else
None
enterprise_catalog_uuid
=
request_data
.
get
(
'
enterprise_customer_catalog_uuid
'
)
if
request_data
else
None
if
enterprise_catalog_uuid
:
if
enterprise_catalog_uuid
:
enterprise_catalog_attribute
,
__
=
BasketAttributeType
.
objects
.
get_or_create
(
enterprise_catalog_attribute
,
__
=
BasketAttributeType
.
objects
.
get_or_create
(
...
...
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