Commit 1fbf4ac0 authored by ibuler's avatar ibuler

[Update] 删除部分资产属性

parent da4c5f48
...@@ -12,9 +12,8 @@ class AssetCreateForm(forms.ModelForm): ...@@ -12,9 +12,8 @@ class AssetCreateForm(forms.ModelForm):
class Meta: class Meta:
model = Asset model = Asset
fields = [ fields = [
'hostname', 'ip', 'public_ip', 'port', 'type', 'comment', 'hostname', 'ip', 'public_ip', 'port', 'comment', 'cluster',
'cluster', 'groups', 'status', 'env', 'is_active', 'groups', 'is_active', 'admin_user', 'labels'
'admin_user', 'labels'
] ]
widgets = { widgets = {
...@@ -61,8 +60,7 @@ class AssetUpdateForm(forms.ModelForm): ...@@ -61,8 +60,7 @@ class AssetUpdateForm(forms.ModelForm):
model = Asset model = Asset
fields = [ fields = [
'hostname', 'ip', 'port', 'groups', "cluster", 'is_active', 'hostname', 'ip', 'port', 'groups', "cluster", 'is_active',
'type', 'env', 'status', 'public_ip', 'remote_card_ip', 'cabinet_no', 'public_ip', 'number', 'comment', 'admin_user', 'labels'
'cabinet_pos', 'number', 'comment', 'admin_user', 'labels'
] ]
widgets = { widgets = {
'groups': forms.SelectMultiple(attrs={ 'groups': forms.SelectMultiple(attrs={
...@@ -94,10 +92,6 @@ class AssetUpdateForm(forms.ModelForm): ...@@ -94,10 +92,6 @@ class AssetUpdateForm(forms.ModelForm):
raise forms.ValidationError(_("You need set a admin user if cluster not have")) raise forms.ValidationError(_("You need set a admin user if cluster not have"))
return self.cleaned_data['admin_user'] return self.cleaned_data['admin_user']
def is_valid(self):
print(self.data)
return super().is_valid()
class AssetBulkUpdateForm(forms.ModelForm): class AssetBulkUpdateForm(forms.ModelForm):
assets = forms.ModelMultipleChoiceField( assets = forms.ModelMultipleChoiceField(
...@@ -117,8 +111,7 @@ class AssetBulkUpdateForm(forms.ModelForm): ...@@ -117,8 +111,7 @@ class AssetBulkUpdateForm(forms.ModelForm):
class Meta: class Meta:
model = Asset model = Asset
fields = [ fields = [
'assets', 'port', 'groups', "cluster", 'assets', 'port', 'groups', "cluster", 'labels'
'type', 'env',
] ]
widgets = { widgets = {
'groups': forms.SelectMultiple( 'groups': forms.SelectMultiple(
......
...@@ -29,25 +29,6 @@ def default_cluster(): ...@@ -29,25 +29,6 @@ def default_cluster():
class Asset(models.Model): class Asset(models.Model):
# Todo: Move them to settings
STATUS_CHOICES = (
('In use', _('In use')),
('Out of use', _('Out of use')),
)
TYPE_CHOICES = (
('Server', _('Server')),
('VM', _('VM')),
('Switch', _('Switch')),
('Router', _('Router')),
('Firewall', _('Firewall')),
('Storage', _("Storage")),
)
ENV_CHOICES = (
('Prod', _('Production')),
('Dev', _('Development')),
('Test', _('Testing')),
)
# Important # Important
id = models.UUIDField(default=uuid.uuid4, primary_key=True) id = models.UUIDField(default=uuid.uuid4, primary_key=True)
ip = models.GenericIPAddressField(max_length=32, verbose_name=_('IP'), db_index=True) ip = models.GenericIPAddressField(max_length=32, verbose_name=_('IP'), db_index=True)
...@@ -56,18 +37,12 @@ class Asset(models.Model): ...@@ -56,18 +37,12 @@ class Asset(models.Model):
groups = models.ManyToManyField(AssetGroup, blank=True, related_name='assets', verbose_name=_('Asset groups')) groups = models.ManyToManyField(AssetGroup, blank=True, related_name='assets', verbose_name=_('Asset groups'))
cluster = models.ForeignKey(Cluster, related_name='assets', default=default_cluster, on_delete=models.SET_DEFAULT, verbose_name=_('Cluster')) cluster = models.ForeignKey(Cluster, related_name='assets', default=default_cluster, on_delete=models.SET_DEFAULT, verbose_name=_('Cluster'))
is_active = models.BooleanField(default=True, verbose_name=_('Is active')) is_active = models.BooleanField(default=True, verbose_name=_('Is active'))
type = models.CharField(choices=TYPE_CHOICES, max_length=16, blank=True, null=True, default='Server', verbose_name=_('Asset type'),)
env = models.CharField(choices=ENV_CHOICES, max_length=8, blank=True, null=True, default='Prod', verbose_name=_('Asset environment'),)
status = models.CharField(choices=STATUS_CHOICES, max_length=12, null=True, blank=True, default='In use', verbose_name=_('Asset status'))
# Auth # Auth
admin_user = models.ForeignKey('assets.AdminUser', null=True, blank=True, on_delete=models.SET_NULL, verbose_name=_("Admin user")) admin_user = models.ForeignKey('assets.AdminUser', null=True, blank=True, on_delete=models.SET_NULL, verbose_name=_("Admin user"))
# Some information # Some information
public_ip = models.GenericIPAddressField(max_length=32, blank=True, null=True, verbose_name=_('Public IP')) public_ip = models.GenericIPAddressField(max_length=32, blank=True, null=True, verbose_name=_('Public IP'))
remote_card_ip = models.CharField(max_length=16, null=True, blank=True, verbose_name=_('Remote control card IP'))
cabinet_no = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Cabinet number'))
cabinet_pos = models.IntegerField(null=True, blank=True, verbose_name=_('Cabinet position'))
number = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Asset number')) number = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Asset number'))
# Collect # Collect
...@@ -89,7 +64,6 @@ class Asset(models.Model): ...@@ -89,7 +64,6 @@ class Asset(models.Model):
hostname_raw = models.CharField(max_length=128, blank=True, null=True, verbose_name=_('Hostname raw')) hostname_raw = models.CharField(max_length=128, blank=True, null=True, verbose_name=_('Hostname raw'))
labels = models.ManyToManyField('assets.Label', blank=True, related_name='assets', verbose_name=_("Labels")) labels = models.ManyToManyField('assets.Label', blank=True, related_name='assets', verbose_name=_("Labels"))
created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by')) created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by'))
date_created = models.DateTimeField(auto_now_add=True, null=True, blank=True, verbose_name=_('Date created')) date_created = models.DateTimeField(auto_now_add=True, null=True, blank=True, verbose_name=_('Date created'))
comment = models.TextField(max_length=128, default='', blank=True, verbose_name=_('Comment')) comment = models.TextField(max_length=128, default='', blank=True, verbose_name=_('Comment'))
......
...@@ -173,7 +173,6 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer): ...@@ -173,7 +173,6 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer):
def get_field_names(self, declared_fields, info): def get_field_names(self, declared_fields, info):
fields = super().get_field_names(declared_fields, info) fields = super().get_field_names(declared_fields, info)
fields.extend([ fields.extend([
'get_type_display', 'get_env_display',
'hardware_info', 'is_connective', 'hardware_info', 'is_connective',
]) ])
return fields return fields
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
{% bootstrap_field form.port layout="horizontal" %} {% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.cluster layout="horizontal" %} {% bootstrap_field form.cluster layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %} {% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.type layout="horizontal" %}
{% bootstrap_field form.env layout="horizontal" %}
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<h3>{% trans 'Auth' %}</h3> <h3>{% trans 'Auth' %}</h3>
......
...@@ -77,22 +77,10 @@ ...@@ -77,22 +77,10 @@
<td></td> <td></td>
{% endif %} {% endif %}
</tr> </tr>
<tr>
<td>{% trans 'Remote card IP' %}:</td>
<td><b>{{ asset.remote_card_ip|default:"" }}</b></td>
</tr>
<tr> <tr>
<td>{% trans 'Cluster' %}:</td> <td>{% trans 'Cluster' %}:</td>
<td><b>{{ asset.cluster.name }}</b></td> <td><b>{{ asset.cluster.name }}</b></td>
</tr> </tr>
<tr>
<td>{% trans 'Cabinet number' %}:</td>
<td><b>{{ asset.cabinet_no|default:"" }}</b></td>
</tr>
<tr>
<td>{% trans 'Cabinet position' %}:</td>
<td><b>{{ asset.cabinet_pos|default:"" }}</b></td>
</tr>
<tr> <tr>
<td>{% trans 'Vendor' %}:</td> <td>{% trans 'Vendor' %}:</td>
<td><b>{{ asset.vendor|default:"" }}</b></td> <td><b>{{ asset.vendor|default:"" }}</b></td>
...@@ -121,22 +109,10 @@ ...@@ -121,22 +109,10 @@
<td>{% trans 'OS' %}:</td> <td>{% trans 'OS' %}:</td>
<td><b>{{ asset.os|default:"" }} {{ asset.os_version|default:"" }} {{ asset.os_arch|default:"" }}</b></td> <td><b>{{ asset.os|default:"" }} {{ asset.os_version|default:"" }} {{ asset.os_arch|default:"" }}</b></td>
</tr> </tr>
<tr>
<td>{% trans 'Asset status' %}:</td>
<td><b>{{ asset.status }}</b></td>
</tr>
<tr> <tr>
<td>{% trans 'Is active' %}:</td> <td>{% trans 'Is active' %}:</td>
<td><b>{{ asset.is_active|yesno:"Yes,No" }}</b></td> <td><b>{{ asset.is_active|yesno:"Yes,No" }}</b></td>
</tr> </tr>
<tr>
<td>{% trans 'Asset type' %}:</td>
<td><b>{{ asset.type }}</b></td>
</tr>
<tr>
<td>{% trans 'Asset environment' %}:</td>
<td><b>{{ asset.env }}</b></td>
</tr>
<tr> <tr>
<td>{% trans 'Serial number' %}:</td> <td>{% trans 'Serial number' %}:</td>
<td><b>{{ asset.sn|default:"" }}</b></td> <td><b>{{ asset.sn|default:"" }}</b></td>
...@@ -250,20 +226,6 @@ ...@@ -250,20 +226,6 @@
<i class="fa fa-info-circle"></i> {% trans 'Labels' %} <i class="fa fa-info-circle"></i> {% trans 'Labels' %}
</div> </div>
<div class="panel-body"> <div class="panel-body">
{# <table class="table">#}
{# <tbody>#}
{# {% for label in asset.labels.all %}#}
{# <tr {% if forloop.counter == 1 %} class="no-borders-tr" {% endif %}>#}
{# <td>{{ label.name }}</td>#}
{# <td>#}
{# <span class="pull-right">#}
{# {{ label.value }}#}
{# </span>#}
{# </td>#}
{# </tr>#}
{# {% endfor %}#}
{# </tbody>#}
{# </table>#}
<ul class="tag-list" style="padding: 0"> <ul class="tag-list" style="padding: 0">
{% for label in asset.labels.all %} {% for label in asset.labels.all %}
<li ><a href=""><i class="fa fa-tag"></i> {{ label.name }}:{{ label.value }}</a></li> <li ><a href=""><i class="fa fa-tag"></i> {{ label.name }}:{{ label.value }}</a></li>
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
{% bootstrap_field form.port layout="horizontal" %} {% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.cluster layout="horizontal" %} {% bootstrap_field form.cluster layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %} {% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.type layout="horizontal" %}
{% bootstrap_field form.env layout="horizontal" %}
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<h3>{% trans 'Auth' %}</h3> <h3>{% trans 'Auth' %}</h3>
...@@ -59,16 +57,9 @@ ...@@ -59,16 +57,9 @@
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<h3>{% trans 'Configuration' %}</h3> <h3>{% trans 'Configuration' %}</h3>
{% bootstrap_field form.number layout="horizontal" %} {% bootstrap_field form.number layout="horizontal" %}
{% bootstrap_field form.remote_card_ip layout="horizontal" %}
<div class="hr-line-dashed"></div>
<h3>{% trans 'Location' %}</h3>
{% bootstrap_field form.cabinet_no layout="horizontal" %}
{% bootstrap_field form.cabinet_pos layout="horizontal" %}
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<h3>{% trans 'Other' %}</h3> <h3>{% trans 'Other' %}</h3>
{% bootstrap_field form.status layout="horizontal" %}
{% bootstrap_field form.comment layout="horizontal" %} {% bootstrap_field form.comment layout="horizontal" %}
{% bootstrap_field form.is_active layout="horizontal" %} {% bootstrap_field form.is_active layout="horizontal" %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment