Commit 58ebe7f3 by Matthew Piatetsky

Search in Mobile - add mobile available flag

ECOM-5040
parent 61460f7a
...@@ -39,6 +39,7 @@ COURSE_RUN_FACET_FIELD_OPTIONS = { ...@@ -39,6 +39,7 @@ COURSE_RUN_FACET_FIELD_OPTIONS = {
'content_type': {}, 'content_type': {},
'type': {}, 'type': {},
'seat_types': {}, 'seat_types': {},
'mobile_available': {},
} }
COURSE_RUN_FACET_FIELD_QUERIES = { COURSE_RUN_FACET_FIELD_QUERIES = {
...@@ -51,7 +52,7 @@ COURSE_RUN_SEARCH_FIELDS = ( ...@@ -51,7 +52,7 @@ COURSE_RUN_SEARCH_FIELDS = (
'text', 'key', 'title', 'short_description', 'full_description', 'start', 'end', 'enrollment_start', 'text', 'key', 'title', 'short_description', 'full_description', 'start', 'end', 'enrollment_start',
'enrollment_end', 'pacing_type', 'language', 'transcript_languages', 'marketing_url', 'content_type', 'org', 'enrollment_end', 'pacing_type', 'language', 'transcript_languages', 'marketing_url', 'content_type', 'org',
'number', 'seat_types', 'image_url', 'type', 'level_type', 'availability', 'published', 'partner', 'program_types', 'number', 'seat_types', 'image_url', 'type', 'level_type', 'availability', 'published', 'partner', 'program_types',
'authoring_organization_uuids', 'subject_uuids', 'staff_uuids', 'authoring_organization_uuids', 'subject_uuids', 'staff_uuids', 'mobile_available',
) )
PROGRAM_FACET_FIELD_OPTIONS = { PROGRAM_FACET_FIELD_OPTIONS = {
...@@ -371,7 +372,7 @@ class CourseRunSerializer(MinimalCourseRunSerializer): ...@@ -371,7 +372,7 @@ class CourseRunSerializer(MinimalCourseRunSerializer):
fields = MinimalCourseRunSerializer.Meta.fields + ( fields = MinimalCourseRunSerializer.Meta.fields + (
'course', 'full_description', 'start', 'end', 'enrollment_start', 'enrollment_end', 'announcement', 'course', 'full_description', 'start', 'end', 'enrollment_start', 'enrollment_end', 'announcement',
'video', 'seats', 'content_language', 'transcript_languages', 'instructors', 'staff', 'pacing_type', 'video', 'seats', 'content_language', 'transcript_languages', 'instructors', 'staff', 'pacing_type',
'min_effort', 'max_effort', 'modified', 'level_type', 'availability', 'min_effort', 'max_effort', 'modified', 'level_type', 'availability', 'mobile_available',
) )
def get_instructors(self, obj): # pylint: disable=unused-argument def get_instructors(self, obj): # pylint: disable=unused-argument
......
...@@ -243,6 +243,7 @@ class CourseRunSerializerTests(MinimalCourseRunSerializerTests): ...@@ -243,6 +243,7 @@ class CourseRunSerializerTests(MinimalCourseRunSerializerTests):
'announcement': json_date_format(course_run.announcement), 'announcement': json_date_format(course_run.announcement),
'video': VideoSerializer(course_run.video).data, 'video': VideoSerializer(course_run.video).data,
'pacing_type': course_run.pacing_type, 'pacing_type': course_run.pacing_type,
'mobile_available': course_run.mobile_available,
'content_language': course_run.language.code, 'content_language': course_run.language.code,
'transcript_languages': [], 'transcript_languages': [],
'min_effort': course_run.min_effort, 'min_effort': course_run.min_effort,
...@@ -1019,6 +1020,7 @@ class CourseRunSearchSerializerTests(TestCase): ...@@ -1019,6 +1020,7 @@ class CourseRunSearchSerializerTests(TestCase):
'key': course_run.key, 'key': course_run.key,
'marketing_url': course_run.marketing_url, 'marketing_url': course_run.marketing_url,
'pacing_type': course_run.pacing_type, 'pacing_type': course_run.pacing_type,
'mobile_available': course_run.mobile_available,
'language': serialize_language(course_run.language), 'language': serialize_language(course_run.language),
'full_description': course_run.full_description, 'full_description': course_run.full_description,
'title': course_run.title, 'title': course_run.title,
......
...@@ -157,6 +157,7 @@ class CoursesApiDataLoader(AbstractDataLoader): ...@@ -157,6 +157,7 @@ class CoursesApiDataLoader(AbstractDataLoader):
'video': self.get_courserun_video(body), 'video': self.get_courserun_video(body),
'status': CourseRunStatus.Published, 'status': CourseRunStatus.Published,
'pacing_type': self.get_pacing_type(body), 'pacing_type': self.get_pacing_type(body),
'mobile_available': body.get('mobile_available'),
}) })
course_run, __ = course.course_runs.update_or_create(key__iexact=key, defaults=defaults) course_run, __ = course.course_runs.update_or_create(key__iexact=key, defaults=defaults)
......
...@@ -467,6 +467,7 @@ class CourseMarketingSiteDataLoader(AbstractMarketingSiteDataLoader): ...@@ -467,6 +467,7 @@ class CourseMarketingSiteDataLoader(AbstractMarketingSiteDataLoader):
'pacing_type': self.get_pacing_type(data), 'pacing_type': self.get_pacing_type(data),
'hidden': self.get_hidden(data), 'hidden': self.get_hidden(data),
'weeks_to_complete': None, 'weeks_to_complete': None,
'mobile_available': data.get('field_course_enrollment_mobile') or False,
} }
if weeks_to_complete: if weeks_to_complete:
......
...@@ -38,6 +38,7 @@ COURSES_API_BODIES = [ ...@@ -38,6 +38,7 @@ COURSES_API_BODIES = [
'short_description': '', 'short_description': '',
'start': '2015-06-15T13:00:00Z', 'start': '2015-06-15T13:00:00Z',
'pacing': 'self', 'pacing': 'self',
'mobile_available': False,
}, },
{ {
'effort': None, 'effort': None,
...@@ -58,7 +59,8 @@ COURSES_API_BODIES = [ ...@@ -58,7 +59,8 @@ COURSES_API_BODIES = [
'org': 'KyotoUx', 'org': 'KyotoUx',
'short_description': '', 'short_description': '',
'start': '2015-10-29T09:00:00Z', 'start': '2015-10-29T09:00:00Z',
'pacing': 'instructor,' 'pacing': 'instructor,',
'mobile_available': False,
}, },
{ {
# Add a second run of KyotoUx+000x (3T2016) to test merging data across # Add a second run of KyotoUx+000x (3T2016) to test merging data across
...@@ -81,6 +83,7 @@ COURSES_API_BODIES = [ ...@@ -81,6 +83,7 @@ COURSES_API_BODIES = [
'org': 'KyotoUx', 'org': 'KyotoUx',
'short_description': '', 'short_description': '',
'start': None, 'start': None,
'mobile_available': False,
}, },
] ]
......
...@@ -178,6 +178,7 @@ class CoursesApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestCas ...@@ -178,6 +178,7 @@ class CoursesApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestCas
'video': self.loader.get_courserun_video(body), 'video': self.loader.get_courserun_video(body),
'status': CourseRunStatus.Published, 'status': CourseRunStatus.Published,
'pacing_type': self.loader.get_pacing_type(body), 'pacing_type': self.loader.get_pacing_type(body),
'mobile_available': body['mobile_available'],
}) })
for field, value in expected_values.items(): for field, value in expected_values.items():
......
...@@ -485,6 +485,7 @@ class CourseMarketingSiteDataLoaderTests(AbstractMarketingSiteDataLoaderTestMixi ...@@ -485,6 +485,7 @@ class CourseMarketingSiteDataLoaderTests(AbstractMarketingSiteDataLoaderTestMixi
'start': start, 'start': start,
'pacing_type': self.loader.get_pacing_type(data), 'pacing_type': self.loader.get_pacing_type(data),
'hidden': self.loader.get_hidden(data), 'hidden': self.loader.get_hidden(data),
'mobile_available': data['field_course_enrollment_mobile'] or False,
} }
if weeks_to_complete: if weeks_to_complete:
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('course_metadata', '0032_auto_20161021_1636'),
]
operations = [
migrations.AddField(
model_name='courserun',
name='mobile_available',
field=models.BooleanField(default=False),
),
]
...@@ -365,6 +365,7 @@ class CourseRun(TimeStampedModel): ...@@ -365,6 +365,7 @@ class CourseRun(TimeStampedModel):
video = models.ForeignKey(Video, default=None, null=True, blank=True) video = models.ForeignKey(Video, default=None, null=True, blank=True)
slug = models.CharField(max_length=255, blank=True, null=True, db_index=True) slug = models.CharField(max_length=255, blank=True, null=True, db_index=True)
hidden = models.BooleanField(default=False) hidden = models.BooleanField(default=False)
mobile_available = models.BooleanField(default=False)
objects = CourseRunQuerySet.as_manager() objects = CourseRunQuerySet.as_manager()
......
...@@ -128,6 +128,7 @@ class CourseRunIndex(BaseCourseIndex, indexes.Indexable): ...@@ -128,6 +128,7 @@ class CourseRunIndex(BaseCourseIndex, indexes.Indexable):
program_types = indexes.MultiValueField() program_types = indexes.MultiValueField()
published = indexes.BooleanField(null=False, faceted=True) published = indexes.BooleanField(null=False, faceted=True)
hidden = indexes.BooleanField(model_attr='hidden', faceted=True) hidden = indexes.BooleanField(model_attr='hidden', faceted=True)
mobile_available = indexes.BooleanField(model_attr='mobile_available', faceted=True)
authoring_organization_uuids = indexes.MultiValueField() authoring_organization_uuids = indexes.MultiValueField()
staff_uuids = indexes.MultiValueField() staff_uuids = indexes.MultiValueField()
subject_uuids = indexes.MultiValueField() subject_uuids = indexes.MultiValueField()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment