|
|
@ -1,17 +1,14 @@
|
|
|
|
import csv
|
|
|
|
|
|
|
|
import codecs
|
|
|
|
import codecs
|
|
|
|
|
|
|
|
import csv
|
|
|
|
from itertools import chain
|
|
|
|
from itertools import chain
|
|
|
|
|
|
|
|
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
|
|
|
|
|
|
|
from settings.serializers import SettingsSerializer
|
|
|
|
|
|
|
|
from common.utils import validate_ip, get_ip_city, get_logger
|
|
|
|
from common.utils import validate_ip, get_ip_city, get_logger
|
|
|
|
from common.db import fields
|
|
|
|
from settings.serializers import SettingsSerializer
|
|
|
|
from .const import DEFAULT_CITY
|
|
|
|
from .const import DEFAULT_CITY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -95,7 +92,7 @@ def _get_instance_field_value(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def model_to_dict_for_operate_log(
|
|
|
|
def model_to_dict_for_operate_log(
|
|
|
|
instance, include_model_fields=True, include_related_fields=True
|
|
|
|
instance, include_model_fields=True, include_related_fields=False
|
|
|
|
):
|
|
|
|
):
|
|
|
|
model_need_continue_fields = ['date_updated']
|
|
|
|
model_need_continue_fields = ['date_updated']
|
|
|
|
m2m_need_continue_fields = ['history_passwords']
|
|
|
|
m2m_need_continue_fields = ['history_passwords']
|
|
|
@ -106,7 +103,7 @@ def model_to_dict_for_operate_log(
|
|
|
|
|
|
|
|
|
|
|
|
if include_related_fields:
|
|
|
|
if include_related_fields:
|
|
|
|
opts = instance._meta
|
|
|
|
opts = instance._meta
|
|
|
|
for f in chain(opts.many_to_many, opts.related_objects):
|
|
|
|
for f in opts.many_to_many:
|
|
|
|
value = []
|
|
|
|
value = []
|
|
|
|
if instance.pk is not None:
|
|
|
|
if instance.pk is not None:
|
|
|
|
related_name = getattr(f, 'attname', '') or getattr(f, 'related_name', '')
|
|
|
|
related_name = getattr(f, 'attname', '') or getattr(f, 'related_name', '')
|
|
|
|