mirror of https://github.com/jumpserver/jumpserver
perf: 优化
parent
e3c0425a7d
commit
33d5cdedea
|
@ -128,20 +128,22 @@ class ActivityOperatorLogSerializer(serializers.Serializer):
|
|||
def get_detail_url(obj):
|
||||
detail_url = ''
|
||||
detail_id, obj_type = obj['r_detail_id'], obj['r_type']
|
||||
if detail_id:
|
||||
if obj_type == ActivityChoices.operate_log:
|
||||
detail_url = reverse(
|
||||
view_name='audits:operate-log-detail',
|
||||
kwargs={'pk': obj['id']},
|
||||
api_to_ui=True, is_audit=True
|
||||
)
|
||||
elif obj_type == ActivityChoices.task:
|
||||
detail_url = reverse(
|
||||
'ops:celery-task-log', kwargs={'pk': detail_id}
|
||||
)
|
||||
elif obj_type == ActivityChoices.login_log:
|
||||
detail_url = '%s?id=%s' % (
|
||||
reverse('api-audits:login-log-list', api_to_ui=True, is_audit=True),
|
||||
detail_id
|
||||
)
|
||||
if not detail_id:
|
||||
return detail_url
|
||||
|
||||
if obj_type == ActivityChoices.operate_log:
|
||||
detail_url = reverse(
|
||||
view_name='audits:operate-log-detail',
|
||||
kwargs={'pk': obj['id']},
|
||||
api_to_ui=True, is_audit=True
|
||||
)
|
||||
elif obj_type == ActivityChoices.task:
|
||||
detail_url = reverse(
|
||||
'ops:celery-task-log', kwargs={'pk': detail_id}
|
||||
)
|
||||
elif obj_type == ActivityChoices.login_log:
|
||||
detail_url = '%s?id=%s' % (
|
||||
reverse('api-audits:login-log-list', api_to_ui=True, is_audit=True),
|
||||
detail_id
|
||||
)
|
||||
return detail_url
|
||||
|
|
|
@ -176,7 +176,7 @@ def on_object_created(
|
|||
'UserLoginLog': activity_handler.login_log_for_activity
|
||||
}
|
||||
model_name = sender._meta.object_name
|
||||
if not created or model_name not in handler_mapping.keys():
|
||||
if not created or model_name not in handler_mapping:
|
||||
return
|
||||
|
||||
resource_id, detail, a_type = handler_mapping[model_name](instance)
|
||||
|
|
Loading…
Reference in New Issue