Commit bf773efa by Vedran Karacic Committed by Ibrahim Ahmed

Add hidden field to Program model

LEARNER-1121
parent def8327c
......@@ -70,6 +70,7 @@ BASE_PROGRAM_FIELDS = (
PROGRAM_SEARCH_FIELDS = BASE_PROGRAM_FIELDS + (
'aggregation_key', 'authoring_organizations', 'authoring_organization_uuids', 'subject_uuids', 'staff_uuids',
'weeks_to_complete_min', 'weeks_to_complete_max', 'min_hours_effort_per_week', 'max_hours_effort_per_week',
'hidden',
)
PROGRAM_FACET_FIELDS = BASE_PROGRAM_FIELDS + ('organizations',)
......@@ -716,7 +717,7 @@ class MinimalProgramSerializer(serializers.ModelSerializer):
class Meta:
model = Program
fields = (
'uuid', 'title', 'subtitle', 'type', 'status', 'marketing_slug', 'marketing_url', 'banner_image',
'uuid', 'title', 'subtitle', 'type', 'status', 'marketing_slug', 'marketing_url', 'banner_image', 'hidden',
'courses', 'authoring_organizations', 'card_image_url', 'is_program_eligible_for_one_click_purchase',
)
read_only_fields = ('uuid', 'marketing_url', 'banner_image')
......
......@@ -594,6 +594,7 @@ class MinimalProgramSerializerTests(TestCase):
'marketing_slug': program.marketing_slug,
'marketing_url': program.marketing_url,
'banner_image': image_field.to_representation(program.banner_image),
'hidden': program.hidden,
'courses': MinimalProgramCourseSerializer(
program.courses,
many=True,
......
......@@ -132,8 +132,8 @@ class CourseRunAdmin(admin.ModelAdmin):
class ProgramAdmin(admin.ModelAdmin):
form = ProgramAdminForm
inlines = [FaqsInline, IndividualEndorsementInline, CorporateEndorsementsInline]
list_display = ('id', 'uuid', 'title', 'type', 'partner', 'status',)
list_filter = ('partner', 'type', 'status', ProgramEligibilityFilter,)
list_display = ('id', 'uuid', 'title', 'type', 'partner', 'status', 'hidden')
list_filter = ('partner', 'type', 'status', ProgramEligibilityFilter, 'hidden',)
ordering = ('uuid', 'title', 'status')
readonly_fields = ('uuid', 'custom_course_runs_display', 'excluded_course_runs',)
search_fields = ('uuid', 'title', 'marketing_slug')
......@@ -146,7 +146,7 @@ class ProgramAdmin(admin.ModelAdmin):
'marketing_slug', 'overview', 'credit_redemption_overview', 'video', 'weeks_to_complete',
'min_hours_effort_per_week', 'max_hours_effort_per_week', 'courses', 'order_courses_by_start_date',
'custom_course_runs_display', 'excluded_course_runs', 'authoring_organizations',
'credit_backing_organizations', 'one_click_purchase_enabled',
'credit_backing_organizations', 'one_click_purchase_enabled', 'hidden',
)
fields += filter_horizontal
save_error = False
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-06-01 16:13
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('course_metadata', '0054_update_program_type_slug_field'),
]
operations = [
migrations.AddField(
model_name='program',
name='hidden',
field=models.BooleanField(db_index=True, default=False, help_text='Hide program on marketing site landing and search pages. This program MAY have a detail page.'),
),
]
......@@ -780,6 +780,9 @@ class Program(TimeStampedModel):
default=False,
help_text=_('Allow courses in this program to be purchased in a single transaction')
)
hidden = models.BooleanField(
default=False, db_index=True,
help_text=_('Hide program on marketing site landing and search pages. This program MAY have a detail page.'))
objects = ProgramQuerySet.as_manager()
......
......@@ -263,6 +263,7 @@ class ProgramFactory(factory.django.DjangoModelFactory):
max_hours_effort_per_week = FuzzyInteger(4)
credit_redemption_overview = FuzzyText()
order_courses_by_start_date = True
hidden = False
@factory.post_generation
def courses(self, create, extracted, **kwargs):
......
......@@ -288,7 +288,7 @@ class ProgramAdminFunctionalTests(LiveServerTestCase):
'field-min_hours_effort_per_week', 'field-max_hours_effort_per_week', 'field-courses',
'field-order_courses_by_start_date', 'field-custom_course_runs_display', 'field-excluded_course_runs',
'field-authoring_organizations', 'field-credit_backing_organizations', 'field-one_click_purchase_enabled',
'field-job_outlook_items', 'field-expected_learning_items',
'field-hidden', 'field-job_outlook_items', 'field-expected_learning_items'
]
self.assertEqual(actual, expected)
......
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