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
2ce0d0c9
Commit
2ce0d0c9
authored
Apr 26, 2018
by
McKenzie Welter
Committed by
McKenzie Welter
Apr 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compare enrollment run key to program data course run list
parent
052a064e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
ecommerce/programs/conditions.py
+2
-2
ecommerce/programs/tests/test_conditions.py
+7
-3
No files found.
ecommerce/programs/conditions.py
View file @
2ce0d0c9
...
@@ -131,10 +131,10 @@ class ProgramCourseRunSeatsCondition(SingleItemConsumptionConditionMixin, Condit
...
@@ -131,10 +131,10 @@ class ProgramCourseRunSeatsCondition(SingleItemConsumptionConditionMixin, Condit
for
course
in
program
[
'courses'
]:
for
course
in
program
[
'courses'
]:
# If the user is already enrolled in a course, we do not need to check their basket for it
# If the user is already enrolled in a course, we do not need to check their basket for it
if
any
(
course
[
'key'
]
in
enrollment
[
'course_details'
][
'course_id'
]
and
if
any
(
enrollment
[
'course_details'
][
'course_id'
]
in
[
run
[
'key'
]
for
run
in
course
[
'course_runs'
]
]
and
enrollment
[
'mode'
]
in
applicable_seat_types
for
enrollment
in
enrollments
):
enrollment
[
'mode'
]
in
applicable_seat_types
for
enrollment
in
enrollments
):
continue
continue
if
any
(
course
[
'uuid'
]
in
entitlement
[
'course_uuid'
]
and
if
any
(
course
[
'uuid'
]
==
entitlement
[
'course_uuid'
]
and
entitlement
[
'mode'
]
in
applicable_seat_types
for
entitlement
in
entitlements
):
entitlement
[
'mode'
]
in
applicable_seat_types
for
entitlement
in
entitlements
):
continue
continue
...
...
ecommerce/programs/tests/test_conditions.py
View file @
2ce0d0c9
...
@@ -92,8 +92,6 @@ class ProgramCourseRunSeatsConditionTests(ProgramTestMixin, TestCase):
...
@@ -92,8 +92,6 @@ class ProgramCourseRunSeatsConditionTests(ProgramTestMixin, TestCase):
program
=
self
.
mock_program_detail_endpoint
(
program
=
self
.
mock_program_detail_endpoint
(
self
.
condition
.
program_uuid
,
self
.
site_configuration
.
discovery_api_url
self
.
condition
.
program_uuid
,
self
.
site_configuration
.
discovery_api_url
)
)
enrollments
=
[{
'mode'
:
'verified'
,
'course_details'
:
{
'course_id'
:
'course-v1:test-org+course+1'
}},
{
'mode'
:
'verified'
,
'course_details'
:
{
'course_id'
:
'course-v1:test-org+course+2'
}}]
# Extract one verified seat for each course
# Extract one verified seat for each course
verified_seats
=
[]
verified_seats
=
[]
...
@@ -103,8 +101,14 @@ class ProgramCourseRunSeatsConditionTests(ProgramTestMixin, TestCase):
...
@@ -103,8 +101,14 @@ class ProgramCourseRunSeatsConditionTests(ProgramTestMixin, TestCase):
if
seat
.
attr
.
id_verification_required
:
if
seat
.
attr
.
id_verification_required
:
verified_seats
.
append
(
seat
)
verified_seats
.
append
(
seat
)
# Add verified enrollments for the first two program courses to the mock user data
enrollments
=
[
{
'mode'
:
'verified'
,
'course_details'
:
{
'course_id'
:
program
[
'courses'
][
0
][
'course_runs'
][
0
][
'key'
]}},
{
'mode'
:
'verified'
,
'course_details'
:
{
'course_id'
:
program
[
'courses'
][
1
][
'course_runs'
][
0
][
'key'
]}}
]
self
.
mock_user_data
(
basket
.
owner
.
username
,
owned_products
=
enrollments
)
self
.
mock_user_data
(
basket
.
owner
.
username
,
owned_products
=
enrollments
)
# If the user has not added all of the remaining courses in program to their basket,
# If the user has not added all of the remaining courses in the program to their basket,
# the condition should not be satisfied
# the condition should not be satisfied
basket
.
flush
()
basket
.
flush
()
for
seat
in
verified_seats
[
2
:
len
(
verified_seats
)
-
1
]:
for
seat
in
verified_seats
[
2
:
len
(
verified_seats
)
-
1
]:
...
...
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