From 63fd3cfff224a52cf4530001744a2e6aa05aa14e Mon Sep 17 00:00:00 2001 From: Webb <343306138@qq.com> Date: Sat, 25 Feb 2017 20:18:13 +0800 Subject: [PATCH] fixed asset_group delete html --- apps/assets/forms.py | 14 ++++++------- .../templates/assets/asset_group_list.html | 4 +++- apps/assets/views.py | 20 +++++++++---------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/apps/assets/forms.py b/apps/assets/forms.py index 602a68c7c..a12f28237 100644 --- a/apps/assets/forms.py +++ b/apps/assets/forms.py @@ -37,13 +37,13 @@ class AssetCreateForm(forms.ModelForm): self.instance.tags.clear() self.instance.tags.add(*tuple(tags)) - def clean(self): - clean_data = super(AssetCreateForm, self).clean() - ip = clean_data.get('ip') - port = clean_data.get('port') - query = Asset.objects.filter(ip=ip, port=port) - if query: - raise forms.ValidationError('this asset has exists.') + # def clean(self): + # clean_data = super(AssetCreateForm, self).clean() + # ip = clean_data.get('ip') + # port = clean_data.get('port') + # query = Asset.objects.filter(ip=ip, port=port) + # if query: + # raise forms.ValidationError('this asset has exists.') class Meta: model = Asset diff --git a/apps/assets/templates/assets/asset_group_list.html b/apps/assets/templates/assets/asset_group_list.html index 1c11ea383..cfa893c31 100644 --- a/apps/assets/templates/assets/asset_group_list.html +++ b/apps/assets/templates/assets/asset_group_list.html @@ -70,7 +70,9 @@ $(document).ready(function(){ var uid = $this.data('uid'); var the_url = '{% url "api-assets:asset-group-detail" pk=99991937 %}'.replace('99991937', uid); objectDelete($this, name, the_url); - $data_table.ajax.reload(); + setTimeout( function () { + $data_table.ajax.reload(); + }, 3000); }) .on('click', '#btn_bulk_update', function () { diff --git a/apps/assets/views.py b/apps/assets/views.py index c0b995733..9a04b5189 100644 --- a/apps/assets/views.py +++ b/apps/assets/views.py @@ -148,16 +148,16 @@ class AssetUpdateView(AdminUserRequiredMixin, UpdateAssetTagsMiXin, UpdateView): # for i in prn_obj_key(form): # if i not in self.new_form.keys(): # print i - # - # #delattr(asset, '"%s" % i') - # #del asset.i - # asset.save() - # asset.id = 27 - # # asset.created_by = self.request.user.username or 'Admin' - # asset.save() - # asset.id = 28 - # asset.save() - # return super(AssetUpdateView, self).form_valid(form) + + #delattr(asset, '"%s" % i') + #del asset.i + asset.save() + asset.id = 27 + # asset.created_by = self.request.user.username or 'Admin' + asset.save() + asset.id = 28 + asset.save() + return super(AssetUpdateView, self).form_valid(form) class AssetDeleteView(DeleteView):