From df2af24cf3d84615e30dc3a1df567c5156fe6e50 Mon Sep 17 00:00:00 2001 From: Awais Date: Wed, 24 Aug 2016 19:55:07 +0500 Subject: [PATCH] ECOM-5344 Type is required field for the admin. Otherwise it throws errors during adding the new program using django-admin. --- course_discovery/apps/course_metadata/admin.py | 2 +- course_discovery/apps/course_metadata/forms.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/course_discovery/apps/course_metadata/admin.py b/course_discovery/apps/course_metadata/admin.py index f94ff65e0a..ee97f0574a 100644 --- a/course_discovery/apps/course_metadata/admin.py +++ b/course_discovery/apps/course_metadata/admin.py @@ -75,7 +75,7 @@ class ProgramAdmin(admin.ModelAdmin): # ordering the field display on admin page. fields = ( - 'title', 'status', 'banner_image_url', 'card_image_url', 'overview', 'video', + 'title', 'status', 'type', 'banner_image_url', 'card_image_url', 'overview', 'video', ) fields += ( 'courses', 'course_runs', 'excluded_course_runs' diff --git a/course_discovery/apps/course_metadata/forms.py b/course_discovery/apps/course_metadata/forms.py index 6f279b08eb..c2fa420d32 100644 --- a/course_discovery/apps/course_metadata/forms.py +++ b/course_discovery/apps/course_metadata/forms.py @@ -9,11 +9,15 @@ class ProgramAdminForm(forms.ModelForm): class Meta: model = Program exclude = ( - 'subtitle', 'category', 'type', 'marketing_slug', 'weeks_to_complete', + 'subtitle', 'category', 'marketing_slug', 'weeks_to_complete', 'min_hours_effort_per_week', 'max_hours_effort_per_week', 'authoring_organizations', ) + def __init__(self, *args, **kwargs): + super(ProgramAdminForm, self).__init__(*args, **kwargs) + self.fields['type'].required = True + class CourseRunSelectionForm(forms.ModelForm):