From c4b52cb2a34434c3bc26dfac089826d7469015c6 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 1 Feb 2018 00:33:00 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E5=8E=BB=E6=8E=89=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E7=BB=84=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/forms.py | 14 +++++++------- apps/assets/models/tree.py | 2 +- apps/assets/templates/assets/asset_create.html | 2 +- apps/assets/templates/assets/tree.html | 5 +++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/assets/forms.py b/apps/assets/forms.py index c93f75626..aac20f090 100644 --- a/apps/assets/forms.py +++ b/apps/assets/forms.py @@ -13,12 +13,12 @@ class AssetCreateForm(forms.ModelForm): model = Asset fields = [ 'hostname', 'ip', 'public_ip', 'port', 'comment', 'cluster', - 'groups', 'is_active', 'admin_user', 'labels' + 'nodes', 'is_active', 'admin_user', 'labels', ] widgets = { - 'groups': forms.SelectMultiple(attrs={ - 'class': 'select2', 'data-placeholder': _('Select asset groups') + 'nodes': forms.SelectMultiple(attrs={ + 'class': 'select2', 'data-placeholder': _('Select nodes') }), 'cluster': forms.Select(attrs={ 'class': 'select2', 'data-placeholder': _('Select cluster') @@ -59,12 +59,12 @@ class AssetUpdateForm(forms.ModelForm): class Meta: model = Asset fields = [ - 'hostname', 'ip', 'port', 'groups', "cluster", 'is_active', - 'public_ip', 'number', 'comment', 'admin_user', 'labels' + 'hostname', 'ip', 'port', 'nodes', "cluster", 'is_active', + 'public_ip', 'number', 'comment', 'admin_user', 'labels', ] widgets = { - 'groups': forms.SelectMultiple(attrs={ - 'class': 'select2', 'data-placeholder': _('Select asset groups') + 'nodes': forms.SelectMultiple(attrs={ + 'class': 'select2', 'data-placeholder': _('Select nodes') }), 'cluster': forms.Select(attrs={ 'class': 'select2', 'data-placeholder': _('Select cluster') diff --git a/apps/assets/models/tree.py b/apps/assets/models/tree.py index 2b070eb7a..38455cd3f 100644 --- a/apps/assets/models/tree.py +++ b/apps/assets/models/tree.py @@ -10,7 +10,7 @@ __all__ = ['Node'] class Node(models.Model): id = models.CharField(primary_key=True, max_length=64) # '1:1:1:1' - name = models.CharField(max_length=128, verbose_name=_("Name")) + name = models.CharField(max_length=128, unique=True, verbose_name=_("Name")) child_mark = models.IntegerField(default=0) date_create = models.DateTimeField(auto_now_add=True) diff --git a/apps/assets/templates/assets/asset_create.html b/apps/assets/templates/assets/asset_create.html index 4c5f12fdd..bf3455934 100644 --- a/apps/assets/templates/assets/asset_create.html +++ b/apps/assets/templates/assets/asset_create.html @@ -26,7 +26,7 @@

{% trans 'Group' %}

- {% bootstrap_field form.groups layout="horizontal" %} + {% bootstrap_field form.nodes layout="horizontal" %}

{% trans 'Labels' %}

diff --git a/apps/assets/templates/assets/tree.html b/apps/assets/templates/assets/tree.html index 8fed0cf35..ce1709340 100644 --- a/apps/assets/templates/assets/tree.html +++ b/apps/assets/templates/assets/tree.html @@ -4,7 +4,7 @@ {% block custom_head_css_js %} - + {# #}