-
Notifications
You must be signed in to change notification settings - Fork 3
/
admin.py
80 lines (58 loc) · 2.1 KB
/
admin.py
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
78
79
80
from django.contrib import admin
# TODO remove import *
from course_selection.models import * # NOQA
class SemesterAdmin(admin.ModelAdmin):
model = Semester
list_display = ('term_code', 'start_date', 'end_date', )
class CourseListingInline(admin.TabularInline):
model = Course_Listing
can_delete = False
class ProfessorInLine(admin.TabularInline):
model = Course.professors.through
readonly_fields = ['prof_name']
def prof_name(self, instance):
return instance.professor.name
prof_name.short_description = 'prof name'
class CourseAdmin(admin.ModelAdmin):
model = Course
inlines = (CourseListingInline, ProfessorInLine)
list_display = ('__unicode__', 'title', 'course_listings', )
list_filter = ('semester', )
ordering = ('-title', )
search_fields = ['title']
class ScheduleAdmin(admin.ModelAdmin):
model = Schedule
list_display = ('title', 'user', 'semester', )
list_filter = ('semester', 'user', )
search_fields = ['user__netid']
class ProfessorAdmin(admin.ModelAdmin):
model = Professor
list_display = ('name', )
search_fields = ['name']
class FriendRequestFromInline(admin.TabularInline):
model = Friend_Request
fk_name = 'from_user'
verbose_name = 'friend-request-from'
extra = 1
class FriendRequestToInline(admin.TabularInline):
model = Friend_Request
fk_name = 'to_user'
verbose_name = 'friend-request-to'
extra = 1
class Nice_UserAdmin(admin.ModelAdmin):
model = Nice_User
inlines = [FriendRequestFromInline, FriendRequestToInline, ]
excludes = ('friends')
list_display = ('netid', )
class FriendRequestAdmin(admin.ModelAdmin):
model = Friend_Request
list_display = ('pk', 'from_user', 'to_user')
admin.site.register(Semester, SemesterAdmin)
admin.site.register(Schedule, ScheduleAdmin)
admin.site.register(Section)
admin.site.register(Meeting)
admin.site.register(Nice_User, Nice_UserAdmin)
admin.site.register(Professor, ProfessorAdmin)
admin.site.register(Color_Palette)
admin.site.register(Course, CourseAdmin)
admin.site.register(Friend_Request, FriendRequestAdmin)