@@ -60,14 +60,43 @@ def owner(self, obj): # pylint: disable=no-self-use
6060 return obj .order .owner
6161
6262
63- class CourseProductRelationInline (admin .TabularInline ):
63+ class CourseProductRelationInline (admin .StackedInline ):
6464 """Admin class for the CourseProductRelation model"""
6565
6666 form = forms .CourseProductRelationAdminForm
6767 model = models .Course .products .through
6868 extra = 0
6969
7070
71+ class CourseCourseRunsInline (admin .TabularInline ):
72+ """Admin class for the CourseCourseRunsInline"""
73+
74+ model = models .CourseRun
75+ show_change_link = True
76+
77+ readonly_fields = (
78+ "title" ,
79+ "resource_link" ,
80+ "enrollment_start" ,
81+ "enrollment_end" ,
82+ "start" ,
83+ "end" ,
84+ "is_listed" ,
85+ "is_gradable" ,
86+ )
87+ fields = (
88+ "title" ,
89+ "resource_link" ,
90+ "enrollment_start" ,
91+ "enrollment_end" ,
92+ "start" ,
93+ "end" ,
94+ "is_listed" ,
95+ "is_gradable" ,
96+ )
97+ extra = 0
98+
99+
71100@admin .register (models .Course )
72101class CourseAdmin (DjangoObjectActions , TranslatableAdmin ):
73102 """Admin class for the Course model"""
@@ -76,10 +105,19 @@ class CourseAdmin(DjangoObjectActions, TranslatableAdmin):
76105 change_actions = (ACTION_NAME_GENERATE_CERTIFICATES ,)
77106 change_form_template = "joanie/admin/translatable_change_form_with_actions.html"
78107 list_display = ("code" , "title" , "state" )
108+ readonly_fields = ("course_runs" ,)
79109 filter_horizontal = ("products" ,)
80- inlines = (CourseProductRelationInline , )
110+ inlines = (CourseCourseRunsInline , CourseProductRelationInline )
81111 fieldsets = (
82- (_ ("Main information" ), {"fields" : ("code" , "title" )}),
112+ (
113+ _ ("Main information" ),
114+ {
115+ "fields" : (
116+ "code" ,
117+ "title" ,
118+ )
119+ },
120+ ),
83121 (
84122 _ ("Organizations" ),
85123 {
@@ -106,7 +144,15 @@ def generate_certificates(self, request, queryset): # pylint: disable no-self-u
106144class CourseRunAdmin (TranslatableAdmin ):
107145 """Admin class for the CourseRun model"""
108146
109- list_display = ("title" , "resource_link" , "start" , "end" , "state" , "is_gradable" )
147+ list_display = (
148+ "title" ,
149+ "resource_link" ,
150+ "start" ,
151+ "end" ,
152+ "state" ,
153+ "is_gradable" ,
154+ "is_listed" ,
155+ )
110156 readonly_fields = ("id" ,)
111157 fieldsets = (
112158 (
0 commit comments