|
1
|
from django.contrib import admin |
|
2
|
|
|
3
|
from core.admin import BaseCoreAdmin |
|
4
|
|
|
5
|
from .agent_claims import TicketClaim |
|
6
|
from .api_tokens import APIToken |
|
7
|
from .branch_protection import BranchProtection |
|
8
|
from .ci import StatusCheck |
|
9
|
from .code_reviews import CodeReview, ReviewComment |
|
10
|
from .forum import ForumPost |
|
11
|
from .models import FossilRepository, FossilSnapshot |
|
12
|
from .notifications import Notification, NotificationPreference, ProjectWatch |
|
13
|
from .releases import Release, ReleaseAsset |
|
14
|
from .sync_models import GitMirror, SSHKey, SyncLog |
|
15
|
from .ticket_fields import TicketFieldDefinition |
|
16
|
from .ticket_reports import TicketReport |
|
17
|
from .user_keys import UserSSHKey |
|
18
|
from .webhooks import Webhook, WebhookDelivery |
|
19
|
from .workspaces import AgentWorkspace |
|
20
|
|
|
21
|
|
|
22
|
class FossilSnapshotInline(admin.TabularInline): |
|
23
|
model = FossilSnapshot |
|
24
|
extra = 0 |
|
25
|
readonly_fields = ("file", "file_size_bytes", "fossil_hash") |
|
26
|
|
|
27
|
|
|
28
|
@admin.register(FossilRepository) |
|
29
|
class FossilRepositoryAdmin(BaseCoreAdmin): |
|
30
|
list_display = ("filename", "project", "file_size_bytes", "checkin_count", "last_checkin_at") |
|
31
|
search_fields = ("filename", "project__name") |
|
32
|
raw_id_fields = ("project",) |
|
33
|
inlines = [FossilSnapshotInline] |
|
34
|
|
|
35
|
|
|
36
|
@admin.register(FossilSnapshot) |
|
37
|
class FossilSnapshotAdmin(BaseCoreAdmin): |
|
38
|
list_display = ("repository", "file_size_bytes", "fossil_hash", "created_at") |
|
39
|
raw_id_fields = ("repository",) |
|
40
|
|
|
41
|
|
|
42
|
class SyncLogInline(admin.TabularInline): |
|
43
|
model = SyncLog |
|
44
|
extra = 0 |
|
45
|
readonly_fields = ("started_at", "completed_at", "status", "artifacts_synced", "triggered_by") |
|
46
|
|
|
47
|
|
|
48
|
@admin.register(GitMirror) |
|
49
|
class GitMirrorAdmin(BaseCoreAdmin): |
|
50
|
list_display = ("repository", "git_remote_url", "sync_mode", "sync_direction", "last_sync_status", "last_sync_at") |
|
51
|
list_filter = ("sync_mode", "sync_direction", "auth_method") |
|
52
|
raw_id_fields = ("repository",) |
|
53
|
inlines = [SyncLogInline] |
|
54
|
|
|
55
|
|
|
56
|
@admin.register(SSHKey) |
|
57
|
class SSHKeyAdmin(BaseCoreAdmin): |
|
58
|
list_display = ("name", "fingerprint", "created_at") |
|
59
|
readonly_fields = ("public_key", "fingerprint") |
|
60
|
|
|
61
|
|
|
62
|
@admin.register(UserSSHKey) |
|
63
|
class UserSSHKeyAdmin(BaseCoreAdmin): |
|
64
|
list_display = ("title", "user", "key_type", "fingerprint", "last_used_at", "created_at") |
|
65
|
list_filter = ("key_type",) |
|
66
|
search_fields = ("title", "user__username", "fingerprint") |
|
67
|
readonly_fields = ("fingerprint", "key_type") |
|
68
|
|
|
69
|
|
|
70
|
@admin.register(Notification) |
|
71
|
class NotificationAdmin(admin.ModelAdmin): |
|
72
|
list_display = ("title", "user", "project", "event_type", "read", "emailed", "created_at") |
|
73
|
list_filter = ("event_type", "read", "emailed") |
|
74
|
search_fields = ("title", "user__username", "project__name") |
|
75
|
raw_id_fields = ("user", "project") |
|
76
|
|
|
77
|
|
|
78
|
@admin.register(ProjectWatch) |
|
79
|
class ProjectWatchAdmin(BaseCoreAdmin): |
|
80
|
list_display = ("user", "project", "event_filter", "email_enabled", "created_at") |
|
81
|
list_filter = ("event_filter", "email_enabled") |
|
82
|
search_fields = ("user__username", "project__name") |
|
83
|
raw_id_fields = ("user", "project") |
|
84
|
|
|
85
|
|
|
86
|
@admin.register(NotificationPreference) |
|
87
|
class NotificationPreferenceAdmin(admin.ModelAdmin): |
|
88
|
list_display = ("user", "delivery_mode", "notify_checkins", "notify_tickets", "notify_wiki", "notify_releases", "notify_forum") |
|
89
|
list_filter = ("delivery_mode",) |
|
90
|
search_fields = ("user__username",) |
|
91
|
raw_id_fields = ("user",) |
|
92
|
|
|
93
|
|
|
94
|
class ReleaseAssetInline(admin.TabularInline): |
|
95
|
model = ReleaseAsset |
|
96
|
extra = 0 |
|
97
|
|
|
98
|
|
|
99
|
@admin.register(Release) |
|
100
|
class ReleaseAdmin(BaseCoreAdmin): |
|
101
|
list_display = ("tag_name", "name", "repository", "is_prerelease", "is_draft", "published_at") |
|
102
|
list_filter = ("is_prerelease", "is_draft") |
|
103
|
search_fields = ("tag_name", "name") |
|
104
|
inlines = [ReleaseAssetInline] |
|
105
|
|
|
106
|
|
|
107
|
@admin.register(ReleaseAsset) |
|
108
|
class ReleaseAssetAdmin(BaseCoreAdmin): |
|
109
|
list_display = ("name", "release", "file_size_bytes", "download_count") |
|
110
|
|
|
111
|
|
|
112
|
@admin.register(SyncLog) |
|
113
|
class SyncLogAdmin(admin.ModelAdmin): |
|
114
|
list_display = ("mirror", "status", "started_at", "completed_at", "artifacts_synced", "triggered_by") |
|
115
|
list_filter = ("status", "triggered_by") |
|
116
|
search_fields = ("mirror__repository__filename", "message") |
|
117
|
raw_id_fields = ("mirror",) |
|
118
|
|
|
119
|
|
|
120
|
@admin.register(ForumPost) |
|
121
|
class ForumPostAdmin(BaseCoreAdmin): |
|
122
|
list_display = ("title", "repository", "parent", "created_by", "created_at") |
|
123
|
search_fields = ("title", "body") |
|
124
|
raw_id_fields = ("repository", "parent", "thread_root") |
|
125
|
|
|
126
|
|
|
127
|
class WebhookDeliveryInline(admin.TabularInline): |
|
128
|
model = WebhookDelivery |
|
129
|
extra = 0 |
|
130
|
readonly_fields = ("event_type", "response_status", "success", "delivered_at", "duration_ms", "attempt") |
|
131
|
|
|
132
|
|
|
133
|
@admin.register(Webhook) |
|
134
|
class WebhookAdmin(BaseCoreAdmin): |
|
135
|
list_display = ("url", "repository", "events", "is_active", "created_at") |
|
136
|
list_filter = ("is_active", "events") |
|
137
|
search_fields = ("url", "repository__filename") |
|
138
|
raw_id_fields = ("repository",) |
|
139
|
inlines = [WebhookDeliveryInline] |
|
140
|
|
|
141
|
|
|
142
|
@admin.register(WebhookDelivery) |
|
143
|
class WebhookDeliveryAdmin(admin.ModelAdmin): |
|
144
|
list_display = ("webhook", "event_type", "response_status", "success", "delivered_at", "duration_ms") |
|
145
|
list_filter = ("success", "event_type") |
|
146
|
raw_id_fields = ("webhook",) |
|
147
|
|
|
148
|
|
|
149
|
@admin.register(StatusCheck) |
|
150
|
class StatusCheckAdmin(BaseCoreAdmin): |
|
151
|
list_display = ("context", "state", "checkin_uuid", "repository", "created_at") |
|
152
|
list_filter = ("state",) |
|
153
|
search_fields = ("context", "checkin_uuid") |
|
154
|
raw_id_fields = ("repository",) |
|
155
|
|
|
156
|
|
|
157
|
@admin.register(APIToken) |
|
158
|
class APITokenAdmin(BaseCoreAdmin): |
|
159
|
list_display = ("name", "token_prefix", "repository", "permissions", "last_used_at", "expires_at", "created_at") |
|
160
|
search_fields = ("name", "token_prefix") |
|
161
|
raw_id_fields = ("repository",) |
|
162
|
readonly_fields = ("token_hash", "token_prefix") |
|
163
|
|
|
164
|
|
|
165
|
@admin.register(BranchProtection) |
|
166
|
class BranchProtectionAdmin(BaseCoreAdmin): |
|
167
|
list_display = ("branch_pattern", "repository", "require_status_checks", "restrict_push", "created_at") |
|
168
|
list_filter = ("require_status_checks", "restrict_push") |
|
169
|
search_fields = ("branch_pattern",) |
|
170
|
raw_id_fields = ("repository",) |
|
171
|
|
|
172
|
|
|
173
|
@admin.register(TicketFieldDefinition) |
|
174
|
class TicketFieldDefinitionAdmin(BaseCoreAdmin): |
|
175
|
list_display = ("name", "label", "repository", "field_type", "is_required", "sort_order") |
|
176
|
list_filter = ("field_type", "is_required") |
|
177
|
search_fields = ("name", "label") |
|
178
|
raw_id_fields = ("repository",) |
|
179
|
|
|
180
|
|
|
181
|
@admin.register(TicketReport) |
|
182
|
class TicketReportAdmin(BaseCoreAdmin): |
|
183
|
list_display = ("title", "repository", "is_public", "created_at") |
|
184
|
list_filter = ("is_public",) |
|
185
|
search_fields = ("title", "description") |
|
186
|
raw_id_fields = ("repository",) |
|
187
|
|
|
188
|
|
|
189
|
@admin.register(AgentWorkspace) |
|
190
|
class AgentWorkspaceAdmin(BaseCoreAdmin): |
|
191
|
list_display = ("name", "repository", "branch", "status", "agent_id", "commits_made", "created_at") |
|
192
|
list_filter = ("status",) |
|
193
|
search_fields = ("name", "agent_id", "branch") |
|
194
|
raw_id_fields = ("repository",) |
|
195
|
|
|
196
|
|
|
197
|
@admin.register(TicketClaim) |
|
198
|
class TicketClaimAdmin(BaseCoreAdmin): |
|
199
|
list_display = ("ticket_uuid", "repository", "agent_id", "status", "claimed_at", "released_at") |
|
200
|
list_filter = ("status",) |
|
201
|
search_fields = ("ticket_uuid", "agent_id") |
|
202
|
raw_id_fields = ("repository", "workspace") |
|
203
|
|
|
204
|
|
|
205
|
class ReviewCommentInline(admin.TabularInline): |
|
206
|
model = ReviewComment |
|
207
|
extra = 0 |
|
208
|
readonly_fields = ("author", "file_path", "line_number", "body", "created_at") |
|
209
|
|
|
210
|
|
|
211
|
@admin.register(CodeReview) |
|
212
|
class CodeReviewAdmin(BaseCoreAdmin): |
|
213
|
list_display = ("title", "repository", "status", "agent_id", "created_at") |
|
214
|
list_filter = ("status",) |
|
215
|
search_fields = ("title", "agent_id", "ticket_uuid") |
|
216
|
raw_id_fields = ("repository", "workspace") |
|
217
|
inlines = [ReviewCommentInline] |
|
218
|
|
|
219
|
|
|
220
|
@admin.register(ReviewComment) |
|
221
|
class ReviewCommentAdmin(BaseCoreAdmin): |
|
222
|
list_display = ("review", "author", "file_path", "line_number", "created_at") |
|
223
|
search_fields = ("body", "author", "file_path") |
|
224
|
raw_id_fields = ("review",) |
|
225
|
|