File tree 1 file changed +30
-1
lines changed
1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 10
10
from django .utils import timezone
11
11
from django .utils .translation import ugettext_lazy as _
12
12
13
+ from messages_extends .admin import MessageAdmin
14
+ from messages_extends .models import Message
15
+ from rest_framework .authtoken .admin import TokenAdmin
16
+
13
17
from readthedocs .core .models import UserProfile
14
18
from readthedocs .projects .models import Project
15
- from rest_framework .authtoken .admin import TokenAdmin
16
19
17
20
18
21
# Monkeypatch raw_id_fields onto the TokenAdmin
@@ -101,6 +104,32 @@ class UserProfileAdmin(admin.ModelAdmin):
101
104
raw_id_fields = ('user' ,)
102
105
103
106
107
+ class MessageAdminExtra (MessageAdmin ):
108
+ list_display = [
109
+ 'user' ,
110
+ 'organizations' ,
111
+ 'message' ,
112
+ 'created' ,
113
+ 'read' ,
114
+ ]
115
+ list_filter = [
116
+ 'read' ,
117
+ ]
118
+ search_fields = [
119
+ 'user__username' ,
120
+ 'message' ,
121
+ 'user__organizationowner__organization__slug' ,
122
+ ]
123
+
124
+ def organizations (self , obj ):
125
+ return ', ' .join (
126
+ organization .slug
127
+ for organization in obj .user .owner_organizations .all ()
128
+ )
129
+
130
+
104
131
admin .site .unregister (User )
105
132
admin .site .register (User , UserAdminExtra )
106
133
admin .site .register (UserProfile , UserProfileAdmin )
134
+ admin .site .unregister (Message )
135
+ admin .site .register (Message , MessageAdminExtra )
You can’t perform that action at this time.
0 commit comments