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
3fe34287
Commit
3fe34287
authored
Sep 04, 2016
by
Vedran Karačić
Committed by
GitHub
Sep 04, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #927 from edx/vkaracic/SOL-2055
Fix condition for multi-offer coupons.
parents
4584a9de
790f5dbe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
8 deletions
+7
-8
ecommerce/coupons/tests/mixins.py
+2
-2
ecommerce/extensions/api/v2/tests/views/test_coupons.py
+2
-5
ecommerce/extensions/voucher/utils.py
+3
-1
No files found.
ecommerce/coupons/tests/mixins.py
View file @
3fe34287
...
@@ -106,7 +106,7 @@ class CouponMixin(object):
...
@@ -106,7 +106,7 @@ class CouponMixin(object):
def
create_coupon
(
self
,
title
=
'Test coupon'
,
price
=
100
,
client
=
None
,
partner
=
None
,
catalog
=
None
,
code
=
''
,
def
create_coupon
(
self
,
title
=
'Test coupon'
,
price
=
100
,
client
=
None
,
partner
=
None
,
catalog
=
None
,
code
=
''
,
benefit_value
=
100
,
note
=
None
,
max_uses
=
None
,
quantity
=
5
,
catalog_query
=
None
,
benefit_value
=
100
,
note
=
None
,
max_uses
=
None
,
quantity
=
5
,
catalog_query
=
None
,
course_seat_types
=
None
,
email_domains
=
None
):
course_seat_types
=
None
,
email_domains
=
None
,
voucher_type
=
Voucher
.
SINGLE_USE
):
"""Helper method for creating a coupon.
"""Helper method for creating a coupon.
Arguments:
Arguments:
...
@@ -141,7 +141,7 @@ class CouponMixin(object):
...
@@ -141,7 +141,7 @@ class CouponMixin(object):
'code'
:
code
,
'code'
:
code
,
'quantity'
:
quantity
,
'quantity'
:
quantity
,
'start_datetime'
:
datetime
.
date
(
2015
,
1
,
1
),
'start_datetime'
:
datetime
.
date
(
2015
,
1
,
1
),
'voucher_type'
:
Voucher
.
SINGLE_USE
,
'voucher_type'
:
voucher_type
,
'categories'
:
[
self
.
category
],
'categories'
:
[
self
.
category
],
'note'
:
note
,
'note'
:
note
,
'max_uses'
:
max_uses
,
'max_uses'
:
max_uses
,
...
...
ecommerce/extensions/api/v2/tests/views/test_coupons.py
View file @
3fe34287
...
@@ -135,22 +135,19 @@ class CouponViewSetTest(CouponMixin, CourseCatalogTestMixin, TestCase):
...
@@ -135,22 +135,19 @@ class CouponViewSetTest(CouponMixin, CourseCatalogTestMixin, TestCase):
def
test_creating_multi_offer_coupon
(
self
):
def
test_creating_multi_offer_coupon
(
self
):
"""Test the creation of a multi-offer coupon."""
"""Test the creation of a multi-offer coupon."""
ordinary_max_uses
=
1
ordinary_coupon
=
self
.
create_coupon
(
quantity
=
2
)
ordinary_coupon
=
self
.
create_coupon
(
quantity
=
2
,
max_uses
=
ordinary_max_uses
)
ordinary_coupon_vouchers
=
ordinary_coupon
.
attr
.
coupon_vouchers
.
vouchers
.
all
()
ordinary_coupon_vouchers
=
ordinary_coupon
.
attr
.
coupon_vouchers
.
vouchers
.
all
()
self
.
assertEqual
(
self
.
assertEqual
(
ordinary_coupon_vouchers
[
0
]
.
offers
.
first
(),
ordinary_coupon_vouchers
[
0
]
.
offers
.
first
(),
ordinary_coupon_vouchers
[
1
]
.
offers
.
first
()
ordinary_coupon_vouchers
[
1
]
.
offers
.
first
()
)
)
self
.
assertEqual
(
ordinary_coupon_vouchers
[
0
]
.
offers
.
first
()
.
max_global_applications
,
ordinary_max_uses
)
multi_offer_coupon
=
self
.
create_coupon
(
quantity
=
2
,
max_uses
=
2
)
multi_offer_coupon
=
self
.
create_coupon
(
quantity
=
2
,
voucher_type
=
Voucher
.
MULTI_USE
)
multi_offer_coupon_vouchers
=
multi_offer_coupon
.
attr
.
coupon_vouchers
.
vouchers
.
all
()
multi_offer_coupon_vouchers
=
multi_offer_coupon
.
attr
.
coupon_vouchers
.
vouchers
.
all
()
first_offer
=
multi_offer_coupon_vouchers
[
0
]
.
offers
.
first
()
first_offer
=
multi_offer_coupon_vouchers
[
0
]
.
offers
.
first
()
second_offer
=
multi_offer_coupon_vouchers
[
1
]
.
offers
.
first
()
second_offer
=
multi_offer_coupon_vouchers
[
1
]
.
offers
.
first
()
self
.
assertNotEqual
(
first_offer
,
second_offer
)
self
.
assertNotEqual
(
first_offer
,
second_offer
)
self
.
assertEqual
(
first_offer
.
max_global_applications
,
second_offer
.
max_global_applications
)
def
test_custom_code_string
(
self
):
def
test_custom_code_string
(
self
):
"""Test creating a coupon with custom voucher code."""
"""Test creating a coupon with custom voucher code."""
...
...
ecommerce/extensions/voucher/utils.py
View file @
3fe34287
...
@@ -423,7 +423,9 @@ def create_vouchers(
...
@@ -423,7 +423,9 @@ def create_vouchers(
# offer because the usage is tied to the offer so that a usage on one voucher would
# offer because the usage is tied to the offer so that a usage on one voucher would
# mean all vouchers will have their usage decreased by one, hence each voucher needs
# mean all vouchers will have their usage decreased by one, hence each voucher needs
# its own offer to keep track of its own usages without interfering with others.
# its own offer to keep track of its own usages without interfering with others.
multi_offer
=
True
if
quantity
>
1
and
max_uses
>
1
else
False
multi_offer
=
True
if
(
voucher_type
==
Voucher
.
MULTI_USE
or
voucher_type
==
Voucher
.
ONCE_PER_CUSTOMER
)
else
False
num_of_offers
=
quantity
if
multi_offer
else
1
num_of_offers
=
quantity
if
multi_offer
else
1
for
num
in
range
(
num_of_offers
):
for
num
in
range
(
num_of_offers
):
offer
=
_get_or_create_offer
(
offer
=
_get_or_create_offer
(
...
...
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