Skip to content

Commit 58335e6

Browse files
admin: add maintainer notes filtering
Comments with an empty msgid are now considered maintainer notes, maintainers should be able to create and update notes for cover and patches. Signed-off-by: Victor Accarini <[email protected]>
1 parent b0889aa commit 58335e6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

patchwork/admin.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# SPDX-License-Identifier: GPL-2.0-or-later
55

66
from django.contrib import admin
7+
from django.contrib.admin import SimpleListFilter
78
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
89
from django.contrib.auth.models import User
910
from django.db.models import Prefetch
@@ -112,7 +113,25 @@ def is_pull_request(self, patch):
112113
admin.site.register(Patch, PatchAdmin)
113114

114115

116+
class MaintainerNoteFilter(SimpleListFilter):
117+
title = 'comment type'
118+
parameter_name = 'type'
119+
120+
def lookups(self, request, model_admin):
121+
return [
122+
('comments', 'Comments'),
123+
('notes', 'Maintainer notes'),
124+
]
125+
126+
def queryset(self, request, queryset):
127+
if self.value() == 'notes':
128+
return queryset.filter(msgid='')
129+
130+
return queryset.exclude(msgid='')
131+
132+
115133
class CoverCommentAdmin(admin.ModelAdmin):
134+
list_filter = [MaintainerNoteFilter]
116135
list_display = ('cover', 'submitter', 'date')
117136
search_fields = ('cover__name', 'submitter__name', 'submitter__email')
118137
date_hierarchy = 'date'
@@ -122,6 +141,7 @@ class CoverCommentAdmin(admin.ModelAdmin):
122141

123142

124143
class PatchCommentAdmin(admin.ModelAdmin):
144+
list_filter = [MaintainerNoteFilter]
125145
list_display = ('patch', 'submitter', 'date')
126146
search_fields = ('patch__name', 'submitter__name', 'submitter__email')
127147
date_hierarchy = 'date'

0 commit comments

Comments
 (0)