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
d1ab9685
Commit
d1ab9685
authored
Mar 20, 2018
by
Bessie Steinberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refresh_meta_data
parent
dfbe351e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
123 additions
and
8 deletions
+123
-8
course_discovery/apps/core/migrations/0008_partner_pubs_api_url.py
+20
-0
course_discovery/apps/core/models.py
+1
-0
course_discovery/apps/course_metadata/admin.py
+2
-3
course_discovery/apps/course_metadata/data_loaders/api.py
+15
-0
course_discovery/apps/course_metadata/management/commands/refresh_course_metadata.py
+4
-1
course_discovery/apps/course_metadata/migrations/0081_auto_20180319_2131.py
+42
-0
course_discovery/apps/course_metadata/migrations/0082_pub_partner.py
+23
-0
course_discovery/apps/course_metadata/models.py
+16
-4
No files found.
course_discovery/apps/core/migrations/0008_partner_pubs_api_url.py
0 → 100644
View file @
d1ab9685
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-03-19 22:02
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0007_auto_20171004_1133'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'partner'
,
name
=
'pubs_api_url'
,
field
=
models
.
URLField
(
blank
=
True
,
max_length
=
255
,
null
=
True
,
verbose_name
=
'Publications API URL'
),
),
]
course_discovery/apps/core/models.py
View file @
d1ab9685
...
@@ -67,6 +67,7 @@ class Partner(TimeStampedModel):
...
@@ -67,6 +67,7 @@ class Partner(TimeStampedModel):
max_length
=
8
,
unique
=
True
,
null
=
False
,
blank
=
False
,
verbose_name
=
_
(
'Short Code'
),
max_length
=
8
,
unique
=
True
,
null
=
False
,
blank
=
False
,
verbose_name
=
_
(
'Short Code'
),
help_text
=
_
(
'Convenient code/slug used to identify this Partner (e.g. for management commands.)'
))
help_text
=
_
(
'Convenient code/slug used to identify this Partner (e.g. for management commands.)'
))
courses_api_url
=
models
.
URLField
(
max_length
=
255
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Courses API URL'
))
courses_api_url
=
models
.
URLField
(
max_length
=
255
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Courses API URL'
))
pubs_api_url
=
models
.
URLField
(
max_length
=
255
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Publications API URL'
))
ecommerce_api_url
=
models
.
URLField
(
max_length
=
255
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'E-Commerce API URL'
))
ecommerce_api_url
=
models
.
URLField
(
max_length
=
255
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'E-Commerce API URL'
))
organizations_api_url
=
models
.
URLField
(
max_length
=
255
,
null
=
True
,
blank
=
True
,
organizations_api_url
=
models
.
URLField
(
max_length
=
255
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Organizations API URL'
))
verbose_name
=
_
(
'Organizations API URL'
))
...
...
course_discovery/apps/course_metadata/admin.py
View file @
d1ab9685
...
@@ -114,10 +114,9 @@ class DigitalBookBundleAdmin(admin.ModelAdmin):
...
@@ -114,10 +114,9 @@ class DigitalBookBundleAdmin(admin.ModelAdmin):
list_display
=
(
list_display
=
(
'id'
,
'id'
,
'uuid'
,
'uuid'
,
'title'
,
'title'
'book_key'
)
)
raw_id_fields
=
(
'courses'
,)
raw_id_fields
=
(
'courses'
,
'pubs'
)
@admin.register
(
Program
)
@admin.register
(
Program
)
...
...
course_discovery/apps/course_metadata/data_loaders/api.py
View file @
d1ab9685
...
@@ -248,6 +248,21 @@ class CoursesApiDataLoader(AbstractDataLoader):
...
@@ -248,6 +248,21 @@ class CoursesApiDataLoader(AbstractDataLoader):
return
video
return
video
# TODO: create publications api
#
# class PubApiDataLoader(AbstractDataLoader):
# """ Loads publications from the Pubs API """
#
# def ingest(self):
# api_url = self.partner.pubs_api_url
# count = None
# page = 1
#
# logger.info('Refreshing publications from %s...', api_url)
#
# while page:
# response = self.api_client.
class
EcommerceApiDataLoader
(
AbstractDataLoader
):
class
EcommerceApiDataLoader
(
AbstractDataLoader
):
""" Loads course seats and entitlements from the E-Commerce API. """
""" Loads course seats and entitlements from the E-Commerce API. """
...
...
course_discovery/apps/course_metadata/management/commands/refresh_course_metadata.py
View file @
d1ab9685
...
@@ -14,7 +14,7 @@ from edx_rest_api_client.client import EdxRestApiClient
...
@@ -14,7 +14,7 @@ from edx_rest_api_client.client import EdxRestApiClient
from
course_discovery.apps.api.cache
import
api_change_receiver
,
set_api_timestamp
from
course_discovery.apps.api.cache
import
api_change_receiver
,
set_api_timestamp
from
course_discovery.apps.core.models
import
Partner
from
course_discovery.apps.core.models
import
Partner
from
course_discovery.apps.course_metadata.data_loaders.api
import
(
from
course_discovery.apps.course_metadata.data_loaders.api
import
(
CoursesApiDataLoader
,
EcommerceApiDataLoader
,
OrganizationsApiDataLoader
,
ProgramsApiDataLoader
CoursesApiDataLoader
,
EcommerceApiDataLoader
,
OrganizationsApiDataLoader
,
ProgramsApiDataLoader
,
PubApiDataLoader
)
)
from
course_discovery.apps.course_metadata.data_loaders.marketing_site
import
(
from
course_discovery.apps.course_metadata.data_loaders.marketing_site
import
(
CourseMarketingSiteDataLoader
,
PersonMarketingSiteDataLoader
,
SchoolMarketingSiteDataLoader
,
CourseMarketingSiteDataLoader
,
PersonMarketingSiteDataLoader
,
SchoolMarketingSiteDataLoader
,
...
@@ -151,6 +151,9 @@ class Command(BaseCommand):
...
@@ -151,6 +151,9 @@ class Command(BaseCommand):
(
CoursesApiDataLoader
,
partner
.
courses_api_url
,
max_workers
),
(
CoursesApiDataLoader
,
partner
.
courses_api_url
,
max_workers
),
),
),
(
(
(
PubApiDataLoader
,
partner
.
pubs_api_url
,
max_workers
),
)
(
(
EcommerceApiDataLoader
,
partner
.
ecommerce_api_url
,
1
),
(
EcommerceApiDataLoader
,
partner
.
ecommerce_api_url
,
1
),
(
ProgramsApiDataLoader
,
partner
.
programs_api_url
,
max_workers
),
(
ProgramsApiDataLoader
,
partner
.
programs_api_url
,
max_workers
),
),
),
...
...
course_discovery/apps/course_metadata/migrations/0081_auto_20180319_2131.py
0 → 100644
View file @
d1ab9685
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-03-19 21:31
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django_extensions.db.fields
import
uuid
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'course_metadata'
,
'0080_auto_20180307_2234'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Pub'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'created'
,
django_extensions
.
db
.
fields
.
CreationDateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'created'
)),
(
'modified'
,
django_extensions
.
db
.
fields
.
ModificationDateTimeField
(
auto_now
=
True
,
verbose_name
=
'modified'
)),
(
'uuid'
,
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
editable
=
False
,
verbose_name
=
'UUID'
)),
(
'key'
,
models
.
CharField
(
max_length
=
255
)),
(
'title'
,
models
.
CharField
(
blank
=
True
,
default
=
None
,
max_length
=
255
,
null
=
True
)),
],
options
=
{
'get_latest_by'
:
'modified'
,
'abstract'
:
False
,
'ordering'
:
(
'-modified'
,
'-created'
),
},
),
migrations
.
RemoveField
(
model_name
=
'digitalbookbundle'
,
name
=
'book_key'
,
),
migrations
.
AddField
(
model_name
=
'digitalbookbundle'
,
name
=
'pubs'
,
field
=
models
.
ManyToManyField
(
blank
=
True
,
to
=
'course_metadata.Pub'
),
),
]
course_discovery/apps/course_metadata/migrations/0082_pub_partner.py
0 → 100644
View file @
d1ab9685
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-03-19 22:02
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0008_partner_pubs_api_url'
),
(
'course_metadata'
,
'0081_auto_20180319_2131'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'pub'
,
name
=
'partner'
,
field
=
models
.
ForeignKey
(
default
=
2
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'core.Partner'
),
preserve_default
=
False
,
),
]
course_discovery/apps/course_metadata/models.py
View file @
d1ab9685
...
@@ -917,9 +917,22 @@ class ProgramType(TimeStampedModel):
...
@@ -917,9 +917,22 @@ class ProgramType(TimeStampedModel):
return
self
.
name
return
self
.
name
class
Pub
(
TimeStampedModel
):
"""" Publication model """
uuid
=
models
.
UUIDField
(
default
=
uuid4
,
editable
=
False
,
verbose_name
=
_
(
'UUID'
))
partner
=
models
.
ForeignKey
(
Partner
)
key
=
models
.
CharField
(
max_length
=
255
)
title
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
def
__str__
(
self
):
return
'{key}: {title}'
.
format
(
key
=
self
.
key
,
title
=
self
.
title
)
class
DigitalBookBundle
(
TimeStampedModel
):
class
DigitalBookBundle
(
TimeStampedModel
):
# TODO: is this an okay assumption to make?
#TODO: rename to ProductBundle
# assumes 1 course and 1 book
uuid
=
models
.
UUIDField
(
uuid
=
models
.
UUIDField
(
blank
=
True
,
blank
=
True
,
default
=
uuid4
,
default
=
uuid4
,
...
@@ -932,8 +945,7 @@ class DigitalBookBundle(TimeStampedModel):
...
@@ -932,8 +945,7 @@ class DigitalBookBundle(TimeStampedModel):
max_length
=
255
,
max_length
=
255
,
unique
=
True
unique
=
True
)
)
#TODO: replace with foreign key
pubs
=
models
.
ManyToManyField
(
Pub
,
blank
=
True
)
book_key
=
models
.
CharField
(
max_length
=
255
)
courses
=
models
.
ManyToManyField
(
Course
,
blank
=
True
)
courses
=
models
.
ManyToManyField
(
Course
,
blank
=
True
)
...
...
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