Skip to content

Commit 868657b

Browse files
committed
Admin 지원 추가
1 parent 04ba510 commit 868657b

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

program/admin.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@admin.register(Program)
99
class ProgramAdmin(ImportExportModelAdmin):
1010
list_display = [
11+
"year",
1112
"id",
1213
"host",
1314
"profile_img",
@@ -18,8 +19,6 @@ class ProgramAdmin(ImportExportModelAdmin):
1819
"end_at",
1920
"program_type",
2021
]
21-
list_filter = [
22-
"program_type",
23-
]
22+
list_filter = ["year", "program_type"]
2423
search_fields = ["title", "host__username"]
2524
resource_class = ProgramResource

session/admin.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from django.contrib import admin
2-
32
from import_export.admin import ImportExportModelAdmin
43

5-
from .models import Proposal, Session, Category
4+
from .models import Category, Proposal, Session
65
from .resources import SessionResource
76

87

@@ -17,9 +16,14 @@ class ProposalAdmin(admin.ModelAdmin):
1716
"duration",
1817
"language",
1918
"category",
19+
"get_year",
2020
]
21-
list_filter = ["accepted", "difficulty", "duration", "language", "category"]
22-
search_fields = ["title", "user__username"]
21+
list_filter = ["category__year", "accepted", "difficulty", "duration", "language", "category"]
22+
search_fields = ["category__year", "title", "user__username"]
23+
24+
@admin.display(ordering="category__year", description="Year")
25+
def get_year(self, obj: Proposal):
26+
return obj.category.year
2327

2428

2529
@admin.register(Session)
@@ -33,14 +37,19 @@ class SessionAdmin(ImportExportModelAdmin):
3337
"duration",
3438
"language",
3539
"category",
40+
"get_year",
3641
]
37-
list_filter = ["difficulty", "duration", "language", "category"]
38-
search_fields = ["title", "user__username"]
42+
list_filter = ["category__year", "difficulty", "duration", "language", "category"]
43+
search_fields = ["category__year", "title", "user__username"]
3944
resource_class = SessionResource
4045

46+
@admin.display(ordering="category__year", description="Year")
47+
def get_year(self, obj: Session):
48+
return obj.category.year
49+
4150

4251
@admin.register(Category)
4352
class CategoryAdmin(admin.ModelAdmin):
44-
list_display = ["id", "name", "visible"]
45-
list_filter = ["visible"]
46-
search_fields = ["name"]
53+
list_display = ["year", "id", "name", "visible"]
54+
list_filter = ["year", "visible"]
55+
search_fields = ["year", "name"]

0 commit comments

Comments
 (0)