12
12
from pyston .utils .decorators import filter_by , order_by
13
13
14
14
from is_core .generic_views .detail_views import DjangoReadonlyDetailView
15
+ from is_core .site import get_model_core
15
16
from is_core .utils import display_code , render_model_object_with_link , render_model_objects_with_link
16
17
from is_core .utils .decorators import short_description
17
18
@@ -142,6 +143,18 @@ def __new__(cls, *args, **kwargs):
142
143
]
143
144
return super ().__new__ (cls )
144
145
146
+ @filter_by ('id' )
147
+ @order_by ('id' )
148
+ @short_description (_ ('short ID' ))
149
+ def short_id (self , obj ):
150
+ return truncatechars (str (obj .id ), 8 )
151
+
152
+ @filter_by ('slug' )
153
+ @order_by ('slug' )
154
+ @short_description (_ ('short slug' ))
155
+ def short_slug (self , obj ):
156
+ return truncatechars (obj .slug , 20 ) if obj .slug is not None else None
157
+
145
158
@short_description (_ ('error message' ))
146
159
@filter_by ('error_message' )
147
160
def error_message_code (self , obj ):
@@ -150,7 +163,13 @@ def error_message_code(self, obj):
150
163
@short_description (_ ('source' ))
151
164
def display_source (self , obj , request ):
152
165
parent_log_obj = self ._get_parent_log_obj (obj )
153
- return render_model_object_with_link (request , parent_log_obj ) if parent_log_obj else None
166
+ if not parent_log_obj :
167
+ return None
168
+ core_parent_model = get_model_core (parent_log_obj .__class__ )
169
+ verbose_name_with_last_id_digits = '{} {}' .format (
170
+ core_parent_model .verbose_name , core_parent_model .short_id (parent_log_obj )
171
+ )
172
+ return render_model_object_with_link (request , parent_log_obj , display_value = verbose_name_with_last_id_digits )
154
173
155
174
def _get_parent_log_obj (self , obj ):
156
175
raise NotImplementedError
@@ -253,9 +272,9 @@ class InputRequestLogCoreMixin(RequestLogCoreMixin):
253
272
menu_group = 'inputrequestlog'
254
273
255
274
list_fields = (
256
- 'id ' , 'start' , 'stop' , 'release ' , 'slug' , ' view_slug' , 'host ' , 'short_path ' , 'state ' , 'time ' , 'method ' ,
257
- 'short_queries ' , 'response_code ' , 'short_request_headers ' , 'short_request_body ' , 'short_response_headers ' ,
258
- 'short_response_body ' , 'user ' , 'ip ' ,
275
+ 'short_id ' , 'start' , 'stop' , 'time ' , 'view_slug' , 'response_code ' , 'state ' , 'method ' , 'host ' , 'short_path ' ,
276
+ 'user ' , 'short_request_body ' , 'short_response_body ' , 'short_queries ' , 'short_request_headers ' ,
277
+ 'short_response_headers ' , 'ip ' , 'release' , 'short_slug ' ,
259
278
)
260
279
261
280
verbose_name = _ ('input request log' )
@@ -302,8 +321,9 @@ class OutputRequestLogCoreMixin(RequestLogCoreMixin):
302
321
menu_group = 'outputrequestlog'
303
322
304
323
list_fields = (
305
- 'id' , 'start' , 'stop' , 'release' , 'slug' , 'host' , 'short_path' , 'state' , 'time' , 'method' , 'short_queries' ,
306
- 'response_code' , 'short_request_headers' , 'short_request_body' , 'short_response_headers' , 'short_response_body'
324
+ 'short_id' , 'start' , 'stop' , 'time' , 'response_code' , 'state' , 'method' , 'host' , 'short_path' ,
325
+ 'short_request_body' , 'short_response_headers' , 'short_queries' , 'short_request_headers' , 'short_response_body' ,
326
+ 'release'
307
327
)
308
328
309
329
fieldsets = (
@@ -344,7 +364,7 @@ class CommandLogCoreMixin(OutputLogCoreMixin, LogCoreMixin):
344
364
menu_group = 'commandlog'
345
365
346
366
list_fields = (
347
- 'id ' , 'start' , 'stop' , 'release ' , 'slug ' , 'name ' , 'state ' , 'time '
367
+ 'short_id ' , 'start' , 'stop' , 'time ' , 'name ' , 'state ' , 'release ' , 'short_slug '
348
368
)
349
369
350
370
verbose_name = _ ('command log' )
@@ -397,10 +417,12 @@ class CeleryTaskRunLogCoreMixin(OutputLogCoreMixin, CeleryCoreMixin, LogCoreMixi
397
417
398
418
menu_group = 'celerytaskrunlog'
399
419
400
- rest_fields = list_fields = (
401
- 'id' , ' start' , 'stop' , 'release ' , 'slug ' , 'celery_task_id ' , 'name ' , 'state ' , 'waiting_time ' , 'time ' ,
402
- 'short_input' , 'queue_name'
420
+ ALL_FIELDS = (
421
+ 'start' , 'stop' , 'time ' , 'name ' , 'state ' , 'short_input ' , 'queue_name ' , 'celery_task_id ' , 'waiting_time ' ,
422
+ 'release' ,
403
423
)
424
+ rest_fields = ('id' , * ALL_FIELDS , 'slug' )
425
+ list_fields = ('short_id' , * ALL_FIELDS , 'short_slug' )
404
426
405
427
verbose_name = _ ('celery task run log' )
406
428
verbose_name_plural = _ ('celery task run logs' )
@@ -440,10 +462,12 @@ class CeleryTaskInvocationLogCoreMixin(CeleryCoreMixin, LogCoreMixin):
440
462
441
463
menu_group = 'celerytaskinvocationlog'
442
464
443
- rest_fields = list_fields = (
444
- 'id' , ' start' , 'stop' , 'release ' , 'slug ' , 'celery_task_id ' , 'name ' , 'state_with_duplicate ' , 'time ' ,
445
- 'short_input ' , 'queue_name '
465
+ ALL_FIELDS = (
466
+ 'start' , 'stop' , 'time ' , 'name ' , 'state_with_duplicate ' , 'short_input ' , 'queue_name ' , 'is_duplicate ' ,
467
+ 'celery_task_id ' , 'release '
446
468
)
469
+ rest_fields = ('id' , * ALL_FIELDS , 'slug' )
470
+ list_fields = ('short_id' , * ALL_FIELDS , 'short_slug' )
447
471
448
472
celery_task_run_inline_table_view = None
449
473
0 commit comments