Added pacing field Course API
ECOM-3994
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('course_overviews', '0009_readd_facebook_url'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='courseoverview',
|
||||
name='facebook_url',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='courseoverview',
|
||||
name='self_paced',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -45,7 +45,7 @@ class CourseOverview(TimeStampedModel):
|
||||
app_label = 'course_overviews'
|
||||
|
||||
# IMPORTANT: Bump this whenever you modify this model and/or add a migration.
|
||||
VERSION = 3
|
||||
VERSION = 4
|
||||
|
||||
# Cache entry versioning.
|
||||
version = IntegerField()
|
||||
@@ -98,6 +98,7 @@ class CourseOverview(TimeStampedModel):
|
||||
short_description = TextField(null=True)
|
||||
course_video_url = TextField(null=True)
|
||||
effort = TextField(null=True)
|
||||
self_paced = BooleanField(default=False)
|
||||
|
||||
@classmethod
|
||||
def _create_from_course(cls, course):
|
||||
@@ -181,6 +182,7 @@ class CourseOverview(TimeStampedModel):
|
||||
short_description=CourseDetails.fetch_about_attribute(course.id, 'short_description'),
|
||||
effort=CourseDetails.fetch_about_attribute(course.id, 'effort'),
|
||||
course_video_url=CourseDetails.fetch_video_url(course.id),
|
||||
self_paced=course.self_paced,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -551,6 +553,16 @@ class CourseOverview(TimeStampedModel):
|
||||
|
||||
return self.apply_cdn_to_urls(urls)
|
||||
|
||||
@property
|
||||
def pacing(self):
|
||||
""" Returns the pacing for the course.
|
||||
|
||||
Potential values:
|
||||
self: Self-paced courses
|
||||
instructor: Instructor-led courses
|
||||
"""
|
||||
return 'self' if self.self_paced else 'instructor'
|
||||
|
||||
def apply_cdn_to_urls(self, image_urls):
|
||||
"""
|
||||
Given a dict of resolutions -> urls, return a copy with CDN applied.
|
||||
|
||||
Reference in New Issue
Block a user