history.py 668 B

12345678910111213141516171819
  1. # Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
  2. # Copyright: (c) <spug.dev@gmail.com>
  3. # Released under the AGPL-3.0 License.
  4. from django.views.generic import View
  5. from django.db.models import F
  6. from libs import json_response
  7. from apps.account.models import History
  8. class HistoryView(View):
  9. def get(self, request):
  10. histories = []
  11. for item in History.objects.annotate(nickname=F('user__nickname')):
  12. histories.append({
  13. 'nickname': item.nickname,
  14. 'ip': item.ip,
  15. 'created_at': item.created_at.split('-', 1)[1],
  16. })
  17. return json_response(histories)