Skip to content

Commit bfa07b0

Browse files
committed
🚸(core) display course runs into admin course change view
On course admin change view, we decided to display related course runs with a modification link to ease content administration.
1 parent e4c58b0 commit bfa07b0

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to
1919

2020
- Allow on-demand page size on the order and enrollment endpoints
2121
- Add yarn cli to generate joanie api client in TypeScript
22+
- Display course runs into the admin course change view
2223

2324
### Removed
2425

src/backend/joanie/core/admin.py

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
72101
class 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
106144
class 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

Comments
 (0)