Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: endpoint api log . #1351

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions dongtai_common/endpoint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ def dispatch(self, request, *args, **kwargs):
except Exception as exc:
logger.warning(f'url: {self.request.path},exc:{exc}', exc_info=exc)
response = self.handle_exception(exc)
finally:
return self.finalize_response(request, response, *args, **kwargs)

self.response = self.finalize_response(request, response, *args,
**kwargs)
Expand Down
31 changes: 14 additions & 17 deletions dongtai_web/views/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,20 @@ def get(self, request):
cur_ids.append(item)
# read log detail
page_data = LogEntry.objects.filter(id__in=cur_ids).order_by('-id').select_related('content_type', 'user')
if page_data:
data = []
for item in page_data:
data.append({
"log_id": item.id,
"user_id": item.user.id,
"username": item.user.username,
"action_time": item.action_time.strftime('%Y-%m-%d %H:%M:%S'),
"content_type": item.content_type.app_labeled_name,
"object_id": item.object_id,
"object_repr": item.object_repr,
"action_flag": item.action_flag,
"change_message": item.change_message,
})
return R.success(data=data, total=total)
else:
return R.failure(msg=_('No permission to access'), status=203)
data = []
for item in page_data:
data.append({
"log_id": item.id,
"user_id": item.user.id,
"username": item.user.username,
"action_time": item.action_time.strftime('%Y-%m-%d %H:%M:%S'),
"content_type": item.content_type.app_labeled_name,
"object_id": item.object_id,
"object_repr": item.object_repr,
"action_flag": item.action_flag,
"change_message": item.change_message,
})
return R.success(data=data, total=total)
except Exception as e:
logger.error(e, exc_info=True)
return R.success(data=list(), msg=_('failure'))