mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 02:48:38 -06:00
Misc cleanup
This commit is contained in:
parent
5f707320ea
commit
ad9c5ca419
@ -100,7 +100,7 @@ class ModuleTypeSerializer(NetBoxModelSerializer):
|
|||||||
model = ModuleType
|
model = ModuleType
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'url', 'display_url', 'display', 'profile', 'manufacturer', 'model', 'part_number', 'airflow',
|
'id', 'url', 'display_url', 'display', 'profile', 'manufacturer', 'model', 'part_number', 'airflow',
|
||||||
'weight', 'weight_unit', 'description', 'attributes', 'comments', 'tags', 'custom_fields', 'created',
|
'weight', 'weight_unit', 'description', 'attribute_data', 'comments', 'tags', 'custom_fields', 'created',
|
||||||
'last_updated',
|
'last_updated',
|
||||||
]
|
]
|
||||||
brief_fields = ('id', 'url', 'display', 'profile', 'manufacturer', 'model', 'description')
|
brief_fields = ('id', 'url', 'display', 'profile', 'manufacturer', 'model', 'description')
|
||||||
|
@ -408,7 +408,8 @@ class DeviceTypeForm(NetBoxModelForm):
|
|||||||
|
|
||||||
class ModuleTypeProfileForm(NetBoxModelForm):
|
class ModuleTypeProfileForm(NetBoxModelForm):
|
||||||
schema = JSONField(
|
schema = JSONField(
|
||||||
label=_('Schema')
|
label=_('Schema'),
|
||||||
|
help_text=_("Enter a valid JSON schema to define supported attributes.")
|
||||||
)
|
)
|
||||||
comments = CommentField()
|
comments = CommentField()
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ from extras.models import ConfigContextModel, CustomField
|
|||||||
from netbox.models import PrimaryModel
|
from netbox.models import PrimaryModel
|
||||||
from netbox.models.features import ImageAttachmentsMixin
|
from netbox.models.features import ImageAttachmentsMixin
|
||||||
from netbox.models.mixins import WeightMixin
|
from netbox.models.mixins import WeightMixin
|
||||||
|
from utilities.string import title
|
||||||
from .device_components import *
|
from .device_components import *
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -131,7 +132,7 @@ class ModuleType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
|
|||||||
return {}
|
return {}
|
||||||
attrs = {}
|
attrs = {}
|
||||||
for name, options in self.profile.schema.get('properties', {}).items():
|
for name, options in self.profile.schema.get('properties', {}).items():
|
||||||
key = options.get('title', name)
|
key = options.get('title', title(name))
|
||||||
attrs[key] = self.attribute_data.get(name)
|
attrs[key] = self.attribute_data.get(name)
|
||||||
return dict(sorted(attrs.items()))
|
return dict(sorted(attrs.items()))
|
||||||
|
|
||||||
|
@ -1486,7 +1486,7 @@ class DeviceTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
class ModuleTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
class ModuleTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||||
queryset = ModuleType.objects.all()
|
queryset = ModuleType.objects.all()
|
||||||
filterset = ModuleTypeFilterSet
|
filterset = ModuleTypeFilterSet
|
||||||
ignore_fields = ['attributes']
|
ignore_fields = ['attribute_data']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{% block title %}{{ object.name }}{% endblock %}
|
{% block title %}{{ object.name }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row mb-3">
|
||||||
<div class="col col-md-6">
|
<div class="col col-md-6">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 class="card-header">{% trans "Module Type Profile" %}</h2>
|
<h2 class="card-header">{% trans "Module Type Profile" %}</h2>
|
||||||
@ -34,13 +34,25 @@
|
|||||||
</h2>
|
</h2>
|
||||||
<pre id="profile_schema">{{ object.schema|json }}</pre>
|
<pre id="profile_schema">{{ object.schema|json }}</pre>
|
||||||
</div>
|
</div>
|
||||||
{% include 'inc/panels/related_objects.html' %}
|
|
||||||
{% include 'inc/panels/custom_fields.html' %}
|
{% include 'inc/panels/custom_fields.html' %}
|
||||||
{% plugin_right_page object %}
|
{% plugin_right_page object %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row mb-3">
|
||||||
<div class="col col-md-12">
|
<div class="col col-md-12">
|
||||||
|
<div class="card">
|
||||||
|
<h2 class="card-header">
|
||||||
|
{% trans "Module Types" %}
|
||||||
|
{% if perms.dcim.add_moduletype %}
|
||||||
|
<div class="card-actions">
|
||||||
|
<a href="{% url 'dcim:moduletype_add' %}?profile={{ object.pk }}" class="btn btn-ghost-primary btn-sm">
|
||||||
|
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Add Module Type" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</h2>
|
||||||
|
{% htmx_table 'dcim:moduletype_list' profile_id=object.pk %}
|
||||||
|
</div>
|
||||||
{% plugin_full_width_page object %}
|
{% plugin_full_width_page object %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user