From 00d3caf80c3da748222a813c3a016fb20c3121d8 Mon Sep 17 00:00:00 2001 From: Bai Date: Fri, 9 Jun 2023 15:57:27 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=88=A0=E9=99=A4=E4=B8=8D=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audits/utils.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/apps/audits/utils.py b/apps/audits/utils.py index d2f6b61cd..239dcfa3f 100644 --- a/apps/audits/utils.py +++ b/apps/audits/utils.py @@ -1,10 +1,8 @@ -import codecs import copy from itertools import chain from datetime import datetime from django.db import models -from django.http import HttpResponse from common.utils.timezone import as_current_tz from common.utils import validate_ip, get_ip_city, get_logger @@ -13,25 +11,6 @@ from .const import DEFAULT_CITY logger = get_logger(__name__) -def get_excel_response(filename): - excel_response = HttpResponse(content_type='text/csv') - excel_response[ - 'Content-Disposition'] = 'attachment; filename="%s"' % filename - excel_response.write(codecs.BOM_UTF8) - return excel_response - - -def write_content_to_excel(response, header=None, login_logs=None, fields=None): - writer = csv.writer(response, dialect='excel', quoting=csv.QUOTE_MINIMAL) - if header: - writer.writerow(header) - if login_logs: - for log in login_logs: - data = [getattr(log, field.name) for field in fields] - writer.writerow(data) - return response - - def write_login_log(*args, **kwargs): from audits.models import UserLoginLog