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
1f3ae3de
Commit
1f3ae3de
authored
Jun 14, 2018
by
Uman Shahzad
Committed by
George Babey
Jun 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix case where we get integrity error due to name.
parent
20c2e807
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
ecommerce/enterprise/forms.py
+6
-3
ecommerce/enterprise/tests/test_forms.py
+18
-4
No files found.
ecommerce/enterprise/forms.py
View file @
1f3ae3de
...
...
@@ -12,7 +12,6 @@ from ecommerce.extensions.offer.models import OFFER_PRIORITY_ENTERPRISE
from
ecommerce.programs.custom
import
class_path
,
create_condition
Benefit
=
get_model
(
'offer'
,
'Benefit'
)
Condition
=
get_model
(
'offer'
,
'Condition'
)
ConditionalOffer
=
get_model
(
'offer'
,
'ConditionalOffer'
)
Range
=
get_model
(
'offer'
,
'Range'
)
...
...
@@ -95,8 +94,12 @@ class EnterpriseOfferForm(forms.ModelForm):
enterprise_customer
=
get_enterprise_customer
(
site
,
enterprise_customer_uuid
)
enterprise_customer_name
=
enterprise_customer
[
'name'
]
self
.
instance
.
name
=
_
(
u'Discount provided by {enterprise_customer_name}.'
.
format
(
enterprise_customer_name
=
enterprise_customer_name
# Note: the actual name is not displayed like this in the template, so it's safe to use the UUID here.
# And in fact we have to, because otherwise we face integrity errors since Oscar forces this name to be unique.
self
.
instance
.
name
=
_
(
u'Discount of type {} provided by {} for {}.'
.
format
(
ConditionalOffer
.
SITE
,
enterprise_customer_name
,
enterprise_customer_catalog_uuid
,
))
self
.
instance
.
status
=
ConditionalOffer
.
OPEN
self
.
instance
.
offer_type
=
ConditionalOffer
.
SITE
...
...
ecommerce/enterprise/tests/test_forms.py
View file @
1f3ae3de
...
...
@@ -118,7 +118,11 @@ class EnterpriseOfferFormTests(EnterpriseServiceMockMixin, TestCase):
data
[
'enterprise_customer_catalog_uuid'
],
data
[
'benefit_value'
],
data
[
'benefit_type'
],
'Discount provided by {}.'
.
format
(
data
[
'enterprise_customer_name'
]),
'Discount of type {} provided by {} for {}.'
.
format
(
ConditionalOffer
.
SITE
,
data
[
'enterprise_customer_name'
],
data
[
'enterprise_customer_catalog_uuid'
]
),
)
@httpretty.activate
...
...
@@ -140,7 +144,9 @@ class EnterpriseOfferFormTests(EnterpriseServiceMockMixin, TestCase):
data
[
'enterprise_customer_catalog_uuid'
],
data
[
'benefit_value'
],
data
[
'benefit_type'
],
'Discount provided by Spánish Enterprise.'
'Discount of type Site provided by Spánish Enterprise for {}.'
.
format
(
data
[
'enterprise_customer_catalog_uuid'
]
),
)
@httpretty.activate
...
...
@@ -164,7 +170,11 @@ class EnterpriseOfferFormTests(EnterpriseServiceMockMixin, TestCase):
data
[
'enterprise_customer_catalog_uuid'
],
data
[
'benefit_value'
],
data
[
'benefit_type'
],
'Discount provided by {}.'
.
format
(
data
[
'enterprise_customer_name'
]),
'Discount of type {} provided by {} for {}.'
.
format
(
ConditionalOffer
.
SITE
,
data
[
'enterprise_customer_name'
],
data
[
'enterprise_customer_catalog_uuid'
]
),
)
@httpretty.activate
...
...
@@ -194,7 +204,11 @@ class EnterpriseOfferFormTests(EnterpriseServiceMockMixin, TestCase):
data
[
'enterprise_customer_catalog_uuid'
],
data
[
'benefit_value'
],
data
[
'benefit_type'
],
'Discount provided by {}.'
.
format
(
data
[
'enterprise_customer_name'
]),
'Discount of type {} provided by {} for {}.'
.
format
(
ConditionalOffer
.
SITE
,
data
[
'enterprise_customer_name'
],
data
[
'enterprise_customer_catalog_uuid'
]
),
)
def
test_create_when_conditional_offer_with_uuid_exists
(
self
):
...
...
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