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
0430072c
Commit
0430072c
authored
Mar 06, 2018
by
Bessie Steinberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
communicate with ecom
parent
4703b408
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
2 deletions
+58
-2
course_discovery/apps/api/serializers.py
+21
-1
course_discovery/apps/api/v1/urls.py
+2
-0
course_discovery/apps/api/v1/views/digital_book_bundles.py
+33
-0
course_discovery/apps/api/v1/views/programs.py
+2
-1
No files found.
course_discovery/apps/api/serializers.py
View file @
0430072c
...
@@ -21,7 +21,7 @@ from course_discovery.apps.core.api_client.lms import LMSAPIClient
...
@@ -21,7 +21,7 @@ from course_discovery.apps.core.api_client.lms import LMSAPIClient
from
course_discovery.apps.course_metadata.choices
import
CourseRunStatus
,
ProgramStatus
from
course_discovery.apps.course_metadata.choices
import
CourseRunStatus
,
ProgramStatus
from
course_discovery.apps.course_metadata.models
import
(
from
course_discovery.apps.course_metadata.models
import
(
FAQ
,
CorporateEndorsement
,
Course
,
CourseEntitlement
,
CourseRun
,
Endorsement
,
Image
,
Organization
,
Person
,
FAQ
,
CorporateEndorsement
,
Course
,
CourseEntitlement
,
CourseRun
,
Endorsement
,
Image
,
Organization
,
Person
,
PersonSocialNetwork
,
PersonWork
,
Position
,
Prerequisite
,
Program
,
ProgramType
,
Seat
,
SeatType
,
Subject
,
Topic
,
PersonSocialNetwork
,
PersonWork
,
Position
,
Prerequisite
,
Program
,
ProgramType
,
DigitalBookBundle
,
Seat
,
SeatType
,
Subject
,
Topic
,
Video
Video
)
)
from
course_discovery.apps.course_metadata.search_indexes
import
CourseIndex
,
CourseRunIndex
,
ProgramIndex
from
course_discovery.apps.course_metadata.search_indexes
import
CourseIndex
,
CourseRunIndex
,
ProgramIndex
...
@@ -954,6 +954,26 @@ class ProgramTypeSerializer(serializers.ModelSerializer):
...
@@ -954,6 +954,26 @@ class ProgramTypeSerializer(serializers.ModelSerializer):
fields
=
(
'name'
,
'logo_image'
,
'applicable_seat_types'
,
'slug'
,)
fields
=
(
'name'
,
'logo_image'
,
'applicable_seat_types'
,
'slug'
,)
class
MinimalDigitalBookBundleSerializer
(
serializers
.
ModelSerializer
):
@classmethod
def
prefetch_queryset
(
cls
):
return
DigitalBookBundle
.
objects
.
all
()
class
Meta
:
model
=
DigitalBookBundle
fields
=
(
'uuid'
,
'title'
,
'book_key'
,
'course'
#TODO: return actual course not course id
)
def
get_course
(
self
,
digital_book_bundle
):
import
pdb
;
pdb
.
set_trace
()
pass
class
AffiliateWindowSerializer
(
serializers
.
ModelSerializer
):
class
AffiliateWindowSerializer
(
serializers
.
ModelSerializer
):
""" Serializer for Affiliate Window product feeds. """
""" Serializer for Affiliate Window product feeds. """
...
...
course_discovery/apps/api/v1/urls.py
View file @
0430072c
...
@@ -12,6 +12,7 @@ from course_discovery.apps.api.v1.views.currency import CurrencyView
...
@@ -12,6 +12,7 @@ from course_discovery.apps.api.v1.views.currency import CurrencyView
from
course_discovery.apps.api.v1.views.organizations
import
OrganizationViewSet
from
course_discovery.apps.api.v1.views.organizations
import
OrganizationViewSet
from
course_discovery.apps.api.v1.views.people
import
PersonViewSet
from
course_discovery.apps.api.v1.views.people
import
PersonViewSet
from
course_discovery.apps.api.v1.views.program_types
import
ProgramTypeViewSet
from
course_discovery.apps.api.v1.views.program_types
import
ProgramTypeViewSet
from
course_discovery.apps.api.v1.views.digital_book_bundles
import
DigitalBookBundleViewSet
from
course_discovery.apps.api.v1.views.programs
import
ProgramViewSet
from
course_discovery.apps.api.v1.views.programs
import
ProgramViewSet
from
course_discovery.apps.api.v1.views.subjects
import
SubjectViewSet
from
course_discovery.apps.api.v1.views.subjects
import
SubjectViewSet
from
course_discovery.apps.api.v1.views.topics
import
TopicViewSet
from
course_discovery.apps.api.v1.views.topics
import
TopicViewSet
...
@@ -36,6 +37,7 @@ router.register(r'subjects', SubjectViewSet, base_name='subject')
...
@@ -36,6 +37,7 @@ router.register(r'subjects', SubjectViewSet, base_name='subject')
router
.
register
(
r'topics'
,
TopicViewSet
,
base_name
=
'topic'
)
router
.
register
(
r'topics'
,
TopicViewSet
,
base_name
=
'topic'
)
router
.
register
(
r'programs'
,
ProgramViewSet
,
base_name
=
'program'
)
router
.
register
(
r'programs'
,
ProgramViewSet
,
base_name
=
'program'
)
router
.
register
(
r'program_types'
,
ProgramTypeViewSet
,
base_name
=
'program_type'
)
router
.
register
(
r'program_types'
,
ProgramTypeViewSet
,
base_name
=
'program_type'
)
router
.
register
(
r'digital_book_bundles'
,
DigitalBookBundleViewSet
,
base_name
=
'digital_book_bundle'
)
router
.
register
(
r'search/all'
,
search_views
.
AggregateSearchViewSet
,
base_name
=
'search-all'
)
router
.
register
(
r'search/all'
,
search_views
.
AggregateSearchViewSet
,
base_name
=
'search-all'
)
router
.
register
(
r'search/courses'
,
search_views
.
CourseSearchViewSet
,
base_name
=
'search-courses'
)
router
.
register
(
r'search/courses'
,
search_views
.
CourseSearchViewSet
,
base_name
=
'search-courses'
)
router
.
register
(
r'search/course_runs'
,
search_views
.
CourseRunSearchViewSet
,
base_name
=
'search-course_runs'
)
router
.
register
(
r'search/course_runs'
,
search_views
.
CourseRunSearchViewSet
,
base_name
=
'search-course_runs'
)
...
...
course_discovery/apps/api/v1/views/digital_book_bundles.py
0 → 100644
View file @
0430072c
from
django_filters.rest_framework
import
DjangoFilterBackend
from
rest_framework
import
viewsets
from
rest_framework.permissions
import
IsAuthenticated
from
rest_framework_extensions.cache.mixins
import
CacheResponseMixin
from
course_discovery.apps.api
import
filters
,
serializers
class
DigitalBookBundleViewSet
(
CacheResponseMixin
,
viewsets
.
ReadOnlyModelViewSet
):
""" Digital Book Bundle resource """
lookup_field
=
'uuid'
lookup_value_regex
=
'[0-9a-f-]+'
permission_classes
=
(
IsAuthenticated
,)
filter_backends
=
(
DjangoFilterBackend
,)
#TODO: figure out what filters are appropriate
# filter_class
#TODO: what pagination should i support
#pagination_class
def
get_serializer_class
(
self
):
if
self
.
action
==
'list'
:
return
serializers
.
MinimalDigitalBookBundleSerializer
# TODO: should this be something different? what is the difference between these two classes?!?
return
serializers
.
MinimalDigitalBookBundleSerializer
def
get_queryset
(
self
):
# This method prevents prefetches on the digital book bundle queryset from "stacking"
# which happens when the queryset is stored in a class property
#TODO: should deals be asscoriated with partners?
return
self
.
get_serializer_class
()
.
prefetch_queryset
()
course_discovery/apps/api/v1/views/programs.py
View file @
0430072c
...
@@ -30,7 +30,8 @@ class ProgramViewSet(CacheResponseMixin, viewsets.ReadOnlyModelViewSet):
...
@@ -30,7 +30,8 @@ class ProgramViewSet(CacheResponseMixin, viewsets.ReadOnlyModelViewSet):
return
serializers
.
ProgramSerializer
return
serializers
.
ProgramSerializer
def
get_queryset
(
self
):
def
get_queryset
(
self
):
# This method prevents prefetches on the program queryset from "stacking,"
# This method prevents prefetc
# hes on the program queryset from "stacking,"
# which happens when the queryset is stored in a class property.
# which happens when the queryset is stored in a class property.
partner
=
self
.
request
.
site
.
partner
partner
=
self
.
request
.
site
.
partner
return
self
.
get_serializer_class
()
.
prefetch_queryset
(
partner
)
return
self
.
get_serializer_class
()
.
prefetch_queryset
(
partner
)
...
...
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