-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathadmin.py
More file actions
95 lines (72 loc) · 2.22 KB
/
Copy pathadmin.py
File metadata and controls
95 lines (72 loc) · 2.22 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from django.contrib import admin
from django.forms import widgets
from .models import (
CfbotBranch,
CfbotTask,
ColorField,
CommitFest,
Committer,
MailThread,
MailThreadAttachment,
Patch,
PatchHistory,
PatchOnCommitFest,
Tag,
TargetVersion,
Topic,
)
class CommitterAdmin(admin.ModelAdmin):
list_display = ("user", "active")
class PatchOnCommitFestInline(admin.TabularInline):
model = PatchOnCommitFest
extra = 1
class PatchAdmin(admin.ModelAdmin):
inlines = (PatchOnCommitFestInline,)
list_display = ("name",)
class MailThreadAdmin(admin.ModelAdmin):
list_display = (
"messageid",
"subject",
"firstmessage",
"latestmsgid",
"latestmessage",
)
class MailThreadAttachmentAdmin(admin.ModelAdmin):
list_display = (
"date",
"author",
"messageid",
"mailthread",
)
class ColorInput(widgets.Input):
"""
A color picker widget.
"""
input_type = "color"
template_name = "color_input.html"
class TagAdmin(admin.ModelAdmin):
# Customize the Tag form with a color picker and soft validation.
change_form_template = "change_tag_form.html"
formfield_overrides = {
ColorField: {"widget": ColorInput},
}
class CfbotBranchAdmin(admin.ModelAdmin):
# Without this the patch field is rendered as a dropdown, for which every
# patch in the database gets fetched and rendered as an <option>. That
# makes the page extremely slow to load. With raw_id_fields it's rendered
# as a simple text input containing the patch id instead.
raw_id_fields = ("patch",)
class CfbotTaskAdmin(admin.ModelAdmin):
# See CfbotBranchAdmin for why raw_id_fields is used here.
raw_id_fields = ("patch",)
admin.site.register(Committer, CommitterAdmin)
admin.site.register(CommitFest)
admin.site.register(Tag, TagAdmin)
admin.site.register(Topic)
admin.site.register(Patch, PatchAdmin)
admin.site.register(PatchHistory)
admin.site.register(TargetVersion)
admin.site.register(CfbotBranch, CfbotBranchAdmin)
admin.site.register(CfbotTask, CfbotTaskAdmin)
admin.site.register(MailThread, MailThreadAdmin)
admin.site.register(MailThreadAttachment, MailThreadAttachmentAdmin)