Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
dfe712e3
Commit
dfe712e3
authored
Jun 06, 2017
by
Michael Frey
Committed by
Michael Frey
Jun 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only check eligible runs that are published
LEARNER-1358
parent
1670a6f3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
course_discovery/apps/course_metadata/models.py
+1
-1
course_discovery/apps/course_metadata/tests/test_admin.py
+1
-1
course_discovery/apps/course_metadata/tests/test_models.py
+26
-1
No files found.
course_discovery/apps/course_metadata/models.py
View file @
dfe712e3
...
...
@@ -805,7 +805,7 @@ class Program(TimeStampedModel):
applicable_seat_types
=
[
seat_type
.
name
.
lower
()
for
seat_type
in
self
.
type
.
applicable_seat_types
.
all
()]
for
course
in
self
.
courses
.
all
():
course_runs
=
set
(
course
.
course_runs
.
all
(
))
-
excluded_course_runs
course_runs
=
set
(
course
.
course_runs
.
filter
(
status
=
CourseRunStatus
.
Published
))
-
excluded_course_runs
if
len
(
course_runs
)
!=
1
:
return
False
...
...
course_discovery/apps/course_metadata/tests/test_admin.py
View file @
dfe712e3
...
...
@@ -387,7 +387,7 @@ class ProgramEligibilityFilterTests(TestCase):
courses
=
[
course_run
.
course
],
one_click_purchase_enabled
=
True
,
)
with
self
.
assertNumQueries
(
1
0
):
with
self
.
assertNumQueries
(
1
1
):
self
.
assertEqual
(
list
(
program_filter
.
queryset
({},
Program
.
objects
.
all
())),
[
one_click_purchase_eligible_program
]
...
...
course_discovery/apps/course_metadata/tests/test_models.py
View file @
dfe712e3
...
...
@@ -15,7 +15,7 @@ from course_discovery.apps.core.models import Currency
from
course_discovery.apps.core.tests.helpers
import
make_image_file
from
course_discovery.apps.core.tests.mixins
import
ElasticsearchTestMixin
from
course_discovery.apps.core.utils
import
SearchQuerySetWrapper
from
course_discovery.apps.course_metadata.choices
import
ProgramStatus
from
course_discovery.apps.course_metadata.choices
import
CourseRunStatus
,
ProgramStatus
from
course_discovery.apps.course_metadata.models
import
(
FAQ
,
AbstractMediaModel
,
AbstractNamedModel
,
AbstractValueModel
,
CorporateEndorsement
,
Course
,
CourseRun
,
Endorsement
,
Seat
,
SeatType
...
...
@@ -523,6 +523,31 @@ class ProgramTests(TestCase):
)
self
.
assertTrue
(
program
.
is_program_eligible_for_one_click_purchase
)
def
test_one_click_purchase_eligible_with_unpublished_runs
(
self
):
""" Verify that program with unpublished course runs is one click purchase eligible. """
verified_seat_type
,
__
=
SeatType
.
objects
.
get_or_create
(
name
=
Seat
.
VERIFIED
)
program_type
=
factories
.
ProgramTypeFactory
(
applicable_seat_types
=
[
verified_seat_type
])
published_course_run
=
factories
.
CourseRunFactory
(
end
=
None
,
enrollment_end
=
None
,
status
=
CourseRunStatus
.
Published
)
unpublished_course_run
=
factories
.
CourseRunFactory
(
end
=
None
,
enrollment_end
=
None
,
status
=
CourseRunStatus
.
Unpublished
,
course
=
published_course_run
.
course
)
factories
.
SeatFactory
(
course_run
=
published_course_run
,
type
=
Seat
.
VERIFIED
,
upgrade_deadline
=
None
)
factories
.
SeatFactory
(
course_run
=
unpublished_course_run
,
type
=
Seat
.
VERIFIED
,
upgrade_deadline
=
None
)
program
=
factories
.
ProgramFactory
(
courses
=
[
published_course_run
.
course
],
one_click_purchase_enabled
=
True
,
type
=
program_type
,
)
self
.
assertTrue
(
program
.
is_program_eligible_for_one_click_purchase
)
def
test_one_click_purchase_ineligible
(
self
):
""" Verify that program is one click purchase ineligible. """
yesterday
=
datetime
.
datetime
.
utcnow
()
-
datetime
.
timedelta
(
days
=
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