-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.py
More file actions
77 lines (60 loc) · 1.97 KB
/
admin.py
File metadata and controls
77 lines (60 loc) · 1.97 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from django.contrib import admin
from .models import Meeting, Month, Trajectory, UserTrajectory
@admin.register(Trajectory)
class TrajectoryAdmin(admin.ModelAdmin):
list_display = (
"id",
"name",
"company",
"start_date",
"duration_months",
)
list_filter = ("company", "start_date",)
search_fields = ("name", "company",)
autocomplete_fields = ("mentors",)
def get_mentors(self, obj):
return ", ".join([mentor.email for mentor in obj.mentors.all()])
get_mentors.short_description = "Наставники"
@admin.register(Month)
class MonthAdmin(admin.ModelAdmin):
list_display = (
"id",
"trajectory",
"skills_list",
)
list_filter = ("trajectory",)
search_fields = ("trajectory__name",)
autocomplete_fields = ("skills",)
def skills_list(self, obj):
return ", ".join(skill.name for skill in obj.skills.all())
skills_list.short_description = "Навыки"
@admin.register(UserTrajectory)
class UserTrajectoryAdmin(admin.ModelAdmin):
list_display = (
"id",
"user",
"trajectory_name",
"start_date",
"is_active",
"mentor",
)
list_filter = ("is_active", "trajectory",)
search_fields = ("user__email", "trajectory__name",)
autocomplete_fields = ("mentor",)
def trajectory_name(self, obj):
return obj.trajectory.name
trajectory_name.short_description = "Траектория"
@admin.register(Meeting)
class MeetingAdmin(admin.ModelAdmin):
list_display = (
"id",
"user_trajectory_user_email",
"initial_meeting",
"final_meeting",
)
readonly_fields = ("user_trajectory",)
list_filter = ("initial_meeting", "final_meeting",)
search_fields = ("user_trajectory__user__email",)
def user_trajectory_user_email(self, obj):
return obj.user_trajectory.user.email
user_trajectory_user_email.short_description = "Пользователь"