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
fa4ff97b
Commit
fa4ff97b
authored
Jun 28, 2018
by
Mushtaq Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add coupon categories - ENT-1053
parent
2bbb1dc9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
2 deletions
+52
-2
AUTHORS
+1
-0
ecommerce/extensions/api/v2/tests/views/test_coupons.py
+8
-1
ecommerce/extensions/api/v2/views/coupons.py
+3
-1
ecommerce/extensions/catalogue/migrations/0032_add_coupon_categories.py
+40
-0
No files found.
AUTHORS
View file @
fa4ff97b
...
@@ -18,3 +18,4 @@ Bill DeRusha <bill@edx.org>
...
@@ -18,3 +18,4 @@ Bill DeRusha <bill@edx.org>
Ivan Ivić <iivic@edx.org>
Ivan Ivić <iivic@edx.org>
Saleem Latif <saleem_ee@hotmail.com>
Saleem Latif <saleem_ee@hotmail.com>
Asad Iqbal <aiqbal@edx.org>
Asad Iqbal <aiqbal@edx.org>
Mushtaq Ali <mushtaak@gmail.com>
ecommerce/extensions/api/v2/tests/views/test_coupons.py
View file @
fa4ff97b
...
@@ -20,7 +20,7 @@ from testfixtures import LogCapture
...
@@ -20,7 +20,7 @@ from testfixtures import LogCapture
from
ecommerce.coupons.tests.mixins
import
CouponMixin
,
DiscoveryMockMixin
from
ecommerce.coupons.tests.mixins
import
CouponMixin
,
DiscoveryMockMixin
from
ecommerce.courses.tests.factories
import
CourseFactory
from
ecommerce.courses.tests.factories
import
CourseFactory
from
ecommerce.extensions.api.v2.views.coupons
import
CouponViewSet
from
ecommerce.extensions.api.v2.views.coupons
import
DEPRECATED_COUPON_CATEGORIES
,
CouponViewSet
from
ecommerce.extensions.catalogue.tests.mixins
import
DiscoveryTestMixin
from
ecommerce.extensions.catalogue.tests.mixins
import
DiscoveryTestMixin
from
ecommerce.extensions.voucher.models
import
CouponVouchers
from
ecommerce.extensions.voucher.models
import
CouponVouchers
from
ecommerce.invoice.models
import
Invoice
from
ecommerce.invoice.models
import
Invoice
...
@@ -1147,3 +1147,10 @@ class CouponCategoriesListViewTests(TestCase):
...
@@ -1147,3 +1147,10 @@ class CouponCategoriesListViewTests(TestCase):
response_data
=
json
.
loads
(
response
.
content
)
response_data
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
response_data
[
'count'
],
1
)
self
.
assertEqual
(
response_data
[
'count'
],
1
)
self
.
assertEqual
(
response_data
[
'results'
][
0
][
'name'
],
'Coupon test category'
)
self
.
assertEqual
(
response_data
[
'results'
][
0
][
'name'
],
'Coupon test category'
)
def
test_deprecated_category_filtering
(
self
):
""" Verify the endpoint doesn't return deprecated coupon categories. """
response
=
self
.
client
.
get
(
self
.
path
)
response_data
=
json
.
loads
(
response
.
content
)
received_coupon_categories
=
[
category
[
'name'
]
for
category
in
response_data
[
'results'
]]
self
.
assertFalse
(
any
(
coupon
in
received_coupon_categories
for
coupon
in
DEPRECATED_COUPON_CATEGORIES
))
ecommerce/extensions/api/v2/views/coupons.py
View file @
fa4ff97b
...
@@ -42,6 +42,8 @@ Range = get_model('offer', 'Range')
...
@@ -42,6 +42,8 @@ Range = get_model('offer', 'Range')
StockRecord
=
get_model
(
'partner'
,
'StockRecord'
)
StockRecord
=
get_model
(
'partner'
,
'StockRecord'
)
Voucher
=
get_model
(
'voucher'
,
'Voucher'
)
Voucher
=
get_model
(
'voucher'
,
'Voucher'
)
DEPRECATED_COUPON_CATEGORIES
=
[
'Bulk Enrollment'
]
class
CouponViewSet
(
EdxOrderPlacementMixin
,
viewsets
.
ModelViewSet
):
class
CouponViewSet
(
EdxOrderPlacementMixin
,
viewsets
.
ModelViewSet
):
""" Coupon resource. """
""" Coupon resource. """
...
@@ -505,4 +507,4 @@ class CouponCategoriesListView(generics.ListAPIView):
...
@@ -505,4 +507,4 @@ class CouponCategoriesListView(generics.ListAPIView):
def
get_queryset
(
self
):
def
get_queryset
(
self
):
parent_category
=
Category
.
objects
.
get
(
slug
=
'coupons'
)
parent_category
=
Category
.
objects
.
get
(
slug
=
'coupons'
)
return
parent_category
.
get_children
()
return
parent_category
.
get_children
()
.
exclude
(
name__in
=
DEPRECATED_COUPON_CATEGORIES
)
ecommerce/extensions/catalogue/migrations/0032_add_coupon_categories.py
0 → 100644
View file @
fa4ff97b
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-06-28 12:17
from
__future__
import
unicode_literals
from
django.db
import
migrations
from
oscar.apps.catalogue.categories
import
create_from_breadcrumbs
from
oscar.core.loading
import
get_model
Category
=
get_model
(
'catalogue'
,
'Category'
)
COUPON_CATEGORY_NAME
=
'Coupons'
DEFAULT_CATEGORIES
=
[
'Bulk Enrollment - Prepay'
,
'Bulk Enrollment - Upon Redemption'
,
'Bulk Enrollment - Integration'
,
]
def
create_default_categories
(
apps
,
schema_editor
):
"""Create default coupon categories."""
for
category
in
DEFAULT_CATEGORIES
:
create_from_breadcrumbs
(
'{} > {}'
.
format
(
COUPON_CATEGORY_NAME
,
category
))
def
remove_default_categories
(
apps
,
schema_editor
):
"""Remove default coupon categories."""
Category
.
objects
.
get
(
name
=
COUPON_CATEGORY_NAME
)
.
get_children
()
.
filter
(
name__in
=
DEFAULT_CATEGORIES
)
.
delete
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'catalogue'
,
'0031_course_entitlement_idverifyreq_attr'
),
]
operations
=
[
migrations
.
RunPython
(
create_default_categories
,
remove_default_categories
)
]
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