From 5b65ed8a19a3e6bc7d5a7ff09e2ec036d4c26293 Mon Sep 17 00:00:00 2001 From: BaiJiangjie Date: Mon, 2 Apr 2018 18:32:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=85=A5=E8=B5=84?= =?UTF-8?q?=E4=BA=A7=E5=88=97=E8=A1=A8IP=E5=AD=97=E6=AE=B5=E5=89=8D?= =?UTF-8?q?=E5=90=8E=E6=9C=89=E7=A9=BA=E6=A0=BC=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=B5=84=E4=BA=A7=E5=88=97=E8=A1=A8=E6=97=B6?= =?UTF-8?q?doamin=E4=BF=9D=E5=AD=98=E4=B8=BA=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/views/asset.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/assets/views/asset.py b/apps/assets/views/asset.py index e279bc0ec..45254c3a4 100644 --- a/apps/assets/views/asset.py +++ b/apps/assets/views/asset.py @@ -28,7 +28,7 @@ from common.mixins import JSONResponseMixin from common.utils import get_object_or_none, get_logger, is_uuid from common.const import create_success_msg, update_success_msg from .. import forms -from ..models import Asset, AdminUser, SystemUser, Label, Node +from ..models import Asset, AdminUser, SystemUser, Label, Node, Domain from ..hands import AdminUserRequiredMixin @@ -279,6 +279,7 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView): asset_dict = dict(zip(attr, row)) id_ = asset_dict.pop('id', 0) for k, v in asset_dict.items(): + v = v.strip() if k == 'is_active': v = True if v in ['TRUE', 1, 'true'] else False elif k == 'admin_user': @@ -288,8 +289,8 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView): v = int(v) except ValueError: v = 0 - else: - continue + elif k == 'domain': + v = get_object_or_none(Domain, name=v) asset_dict[k] = v asset = get_object_or_none(Asset, id=id_) if is_uuid(id_) else None