-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathadmin.py
More file actions
55 lines (46 loc) · 1.51 KB
/
Copy pathadmin.py
File metadata and controls
55 lines (46 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from django.contrib import admin
from import_export.admin import ImportExportModelAdmin
from .models import Category, Proposal, Session
from .resources import SessionResource
@admin.register(Proposal)
class ProposalAdmin(admin.ModelAdmin):
list_display = [
"id",
"title",
"user",
"accepted",
"difficulty",
"duration",
"language",
"category",
"get_year",
]
list_filter = ["category__year", "accepted", "difficulty", "duration", "language", "category"]
search_fields = ["category__year", "title", "user__username"]
@admin.display(ordering="category__year", description="Year")
def get_year(self, obj: Proposal):
return obj.category.year
@admin.register(Session)
class SessionAdmin(ImportExportModelAdmin):
list_display = [
"id",
"title",
"host_profile_image",
"host_name",
"difficulty",
"duration",
"language",
"category",
"get_year",
]
list_filter = ["category__year", "difficulty", "duration", "language", "category"]
search_fields = ["category__year", "title", "user__username"]
resource_class = SessionResource
@admin.display(ordering="category__year", description="Year")
def get_year(self, obj: Session):
return obj.category.year
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
list_display = ["year", "id", "name", "visible"]
list_filter = ["year", "visible"]
search_fields = ["year", "name"]