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
996c385e
Commit
996c385e
authored
Apr 04, 2017
by
Vedran Karacic
Committed by
Vedran Karačić
Apr 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add applicable seat types to individual programs serializer.
parent
64b6ee57
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
+10
-5
course_discovery/apps/api/serializers.py
+5
-1
course_discovery/apps/api/tests/test_serializers.py
+2
-1
course_discovery/apps/api/v1/tests/test_views/test_programs.py
+3
-3
No files found.
course_discovery/apps/api/serializers.py
View file @
996c385e
...
...
@@ -820,6 +820,7 @@ class ProgramSerializer(MinimalProgramSerializer):
)
subjects
=
SubjectSerializer
(
many
=
True
)
staff
=
PersonSerializer
(
many
=
True
)
applicable_seat_types
=
serializers
.
SerializerMethodField
()
@classmethod
def
prefetch_queryset
(
cls
):
...
...
@@ -848,6 +849,9 @@ class ProgramSerializer(MinimalProgramSerializer):
Prefetch
(
'individual_endorsements'
,
queryset
=
EndorsementSerializer
.
prefetch_queryset
()),
)
def
get_applicable_seat_types
(
self
,
obj
):
return
list
(
obj
.
type
.
applicable_seat_types
.
values_list
(
'slug'
,
flat
=
True
))
class
Meta
(
MinimalProgramSerializer
.
Meta
):
model
=
Program
fields
=
MinimalProgramSerializer
.
Meta
.
fields
+
(
...
...
@@ -855,7 +859,7 @@ class ProgramSerializer(MinimalProgramSerializer):
'min_hours_effort_per_week'
,
'max_hours_effort_per_week'
,
'video'
,
'expected_learning_items'
,
'faq'
,
'credit_backing_organizations'
,
'corporate_endorsements'
,
'job_outlook_items'
,
'individual_endorsements'
,
'languages'
,
'transcript_languages'
,
'subjects'
,
'price_ranges'
,
'staff'
,
'credit_redemption_overview'
,
'staff'
,
'credit_redemption_overview'
,
'applicable_seat_types'
)
...
...
course_discovery/apps/api/tests/test_serializers.py
View file @
996c385e
...
...
@@ -621,6 +621,7 @@ class ProgramSerializerTests(MinimalProgramSerializerTests):
'authoring_organizations'
:
OrganizationSerializer
(
program
.
authoring_organizations
,
many
=
True
)
.
data
,
'video'
:
VideoSerializer
(
program
.
video
)
.
data
,
'credit_redemption_overview'
:
program
.
credit_redemption_overview
,
'applicable_seat_types'
:
list
(
program
.
type
.
applicable_seat_types
.
values_list
(
'slug'
,
flat
=
True
)),
'corporate_endorsements'
:
CorporateEndorsementSerializer
(
program
.
corporate_endorsements
,
many
=
True
)
.
data
,
'credit_backing_organizations'
:
OrganizationSerializer
(
program
.
credit_backing_organizations
,
...
...
@@ -642,7 +643,7 @@ class ProgramSerializerTests(MinimalProgramSerializerTests):
'overview'
:
program
.
overview
,
'price_ranges'
:
program
.
price_ranges
,
'subjects'
:
SubjectSerializer
(
program
.
subjects
,
many
=
True
)
.
data
,
'transcript_languages'
:
[
serialize_language_to_code
(
l
)
for
l
in
program
.
transcript_languages
]
'transcript_languages'
:
[
serialize_language_to_code
(
l
)
for
l
in
program
.
transcript_languages
]
,
})
return
expected
...
...
course_discovery/apps/api/v1/tests/test_views/test_programs.py
View file @
996c385e
...
...
@@ -64,7 +64,7 @@ class ProgramViewSetTests(SerializationMixin, APITestCase):
def
test_retrieve
(
self
):
""" Verify the endpoint returns the details for a single program. """
program
=
self
.
create_program
()
with
self
.
assertNumQueries
(
4
1
):
with
self
.
assertNumQueries
(
4
2
):
response
=
self
.
assert_retrieve_success
(
program
)
assert
response
.
data
==
self
.
serialize_program
(
program
)
...
...
@@ -75,7 +75,7 @@ class ProgramViewSetTests(SerializationMixin, APITestCase):
for
course
in
course_list
:
CourseRunFactory
(
course
=
course
)
program
=
ProgramFactory
(
courses
=
course_list
,
order_courses_by_start_date
=
order_courses_by_start_date
)
with
self
.
assertNumQueries
(
2
8
):
with
self
.
assertNumQueries
(
2
9
):
response
=
self
.
assert_retrieve_success
(
program
)
assert
response
.
data
==
self
.
serialize_program
(
program
)
self
.
assertEqual
(
course_list
,
list
(
program
.
courses
.
all
()))
# pylint: disable=no-member
...
...
@@ -84,7 +84,7 @@ class ProgramViewSetTests(SerializationMixin, APITestCase):
""" Verify the endpoint returns data for a program even if the program's courses have no course runs. """
course
=
CourseFactory
()
program
=
ProgramFactory
(
courses
=
[
course
])
with
self
.
assertNumQueries
(
19
):
with
self
.
assertNumQueries
(
20
):
response
=
self
.
assert_retrieve_success
(
program
)
assert
response
.
data
==
self
.
serialize_program
(
program
)
...
...
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