Skip to content

Commit

Permalink
Merge pull request #134 from druids/UseStandardEnumSerializer
Browse files Browse the repository at this point in the history
Use standard serializer to get enum in core
  • Loading branch information
matllubos committed Jan 27, 2022
2 parents 6f5186d + 6c969ee commit 3627a2e
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 147 deletions.
26 changes: 13 additions & 13 deletions security/backends/common/is_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ def __new__(cls, *args, **kwargs):

@filter_by('id')
@order_by('id')
@short_description(_('short ID'))
@short_description(_('ID'))
def short_id(self, obj):
return obj.short_id

@filter_by('slug')
@order_by('slug')
@short_description(_('short slug'))
@short_description(_('slug'))
def short_slug(self, obj):
return truncatechars(obj.slug, 20) if obj.slug is not None else None

Expand All @@ -164,12 +164,6 @@ def display_source(self, obj, request):
parent_log_obj = self._get_parent_log_obj(obj)
return render_model_object_with_link(request, parent_log_obj) if parent_log_obj else None

@filter_by('state')
@order_by('state')
@short_description(_('state'))
def state_display(self, obj):
return obj.state.label

def _get_parent_log_obj(self, obj):
raise NotImplementedError

Expand Down Expand Up @@ -271,7 +265,7 @@ class InputRequestLogCoreMixin(RequestLogCoreMixin):
menu_group = 'inputrequestlog'

list_fields = (
'short_id', 'start', 'stop', 'time', 'view_slug', 'response_code', 'state_display', 'method', 'host',
'short_id', 'start', 'stop', 'time', 'short_view_slug', 'response_code', 'state', 'method', 'host',
'short_path', 'user', 'short_request_body', 'short_response_body', 'short_queries', 'short_request_headers',
'short_response_headers', 'ip', 'release', 'short_slug',
)
Expand Down Expand Up @@ -307,6 +301,12 @@ def get_fieldsets(self, request, obj=None):
(None, {'fields': ('debug_toolbar',)})
)

@filter_by('view_slug')
@order_by('view_slug')
@short_description(_('view slug'))
def short_view_slug(self, obj):
return truncatechars(obj.view_slug, 20) if obj.view_slug is not None else None

@short_description('')
def debug_toolbar(self, obj):
return (
Expand All @@ -320,7 +320,7 @@ class OutputRequestLogCoreMixin(RequestLogCoreMixin):
menu_group = 'outputrequestlog'

list_fields = (
'short_id', 'start', 'stop', 'time', 'response_code', 'state_display', 'method', 'host', 'short_path',
'short_id', 'start', 'stop', 'time', 'response_code', 'state', 'method', 'host', 'short_path',
'short_request_body', 'short_response_body', 'short_queries', 'short_request_headers', 'short_response_headers',
'release', 'slug'
)
Expand Down Expand Up @@ -363,7 +363,7 @@ class CommandLogCoreMixin(OutputLogCoreMixin, LogCoreMixin):
menu_group = 'commandlog'

list_fields = (
'short_id', 'start', 'stop', 'time', 'name', 'state_display', 'release', 'short_slug'
'short_id', 'start', 'stop', 'time', 'name', 'state', 'release', 'short_slug'
)

verbose_name = _('command log')
Expand Down Expand Up @@ -399,7 +399,7 @@ class CeleryCoreMixin(LogCoreMixin):

@filter_by('celery_task_id')
@order_by('celery_task_id')
@short_description(_('celery task short ID'))
@short_description(_('celery task ID'))
def celery_task_short_id(self, obj):
return truncatechars(obj.celery_task_id, 8)

Expand All @@ -423,7 +423,7 @@ class CeleryTaskRunLogCoreMixin(OutputLogCoreMixin, CeleryCoreMixin, LogCoreMixi
menu_group = 'celerytaskrunlog'

list_fields = (
'short_id', 'start', 'stop', 'time', 'name', 'state_display', 'short_input', 'queue_name',
'short_id', 'start', 'stop', 'time', 'name', 'state', 'short_input', 'queue_name',
'celery_task_short_id', 'waiting_time', 'release', 'short_slug'
)
rest_fields = list_fields + ('id',)
Expand Down
Loading

0 comments on commit 3627a2e

Please sign in to comment.