Skip to content

Commit

Permalink
Merge pull request #1351 from Bidaya0/fix/endpoint-log-fix
Browse files Browse the repository at this point in the history
fix: endpoint api log .
  • Loading branch information
Bidaya0 authored Mar 21, 2023
2 parents 5a7a671 + caf8a4a commit b51bcb6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
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'))

0 comments on commit b51bcb6

Please sign in to comment.