@@ -75,6 +75,20 @@ def order_link_formatter(model: Any, name: Any) -> Any:
7575 return 'N/A'
7676 return Markup (f'<a href="/admin/order/details/{ order_id } ">{ order_id } </a>' )
7777
78+ @staticmethod
79+ def docs_link_formatter (model : Any , name : Any ) -> Any :
80+ docs = getattr (model , name )
81+ if not docs :
82+ return 'No docs'
83+ links = []
84+ if isinstance (docs , dict ):
85+ for doc_type , s3_key in docs .items ():
86+ links .append (
87+ f'<a href="/api/v1/media/view?key={ s3_key } " '
88+ f'target="_blank">{ doc_type } </a>'
89+ )
90+ return Markup (', ' .join (links ))
91+
7892
7993class VerificationRequestAdmin (ModelView , model = VerificationRequest ):
8094 column_list = [
@@ -93,6 +107,7 @@ class VerificationRequestAdmin(ModelView, model=VerificationRequest):
93107 'user_id' : AdminPanelFormatter .user_link_formatter ,
94108 'target_role' : AdminPanelFormatter .status_formatter ,
95109 'status' : AdminPanelFormatter .status_formatter ,
110+ 'docs_url' : AdminPanelFormatter .docs_link_formatter ,
96111 }
97112 column_formatters_detail = column_formatters
98113 name = 'Verification Request'
@@ -156,6 +171,7 @@ class ProductAdmin(ModelView, model=Product):
156171 Product .status ,
157172 Product .owner_id ,
158173 Product .moderator_id ,
174+ Product .moderation_comment ,
159175 ]
160176 column_labels = {'qty_available' : 'Quantity Available' }
161177 column_default_sort = [('created_at' , True )]
@@ -165,11 +181,21 @@ class ProductAdmin(ModelView, model=Product):
165181 'moderator_id' : AdminPanelFormatter .user_link_formatter ,
166182 }
167183 column_formatters_detail = column_formatters
168- column_searchable_list = [Product .id , Product .name , Product .description ]
184+ column_searchable_list = [
185+ Product .id ,
186+ Product .name ,
187+ Product .description ,
188+ Product .moderation_comment ,
189+ ]
169190 can_delete = False
170191 name = 'Product'
171192 name_plural = 'Products'
172193 icon = 'fa-solid fa-box'
194+ form_columns = [
195+ Product .status ,
196+ Product .moderator_id ,
197+ Product .moderation_comment ,
198+ ]
173199
174200
175201class OrderAdmin (ModelView , model = Order ):
0 commit comments