mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-15 03:32:53 -06:00
refactored UI for local config context
This commit is contained in:
parent
e3e9211e8a
commit
4039753b2f
@ -412,7 +412,7 @@ class DeviceSerializer(TaggitSerializer, CustomFieldModelSerializer):
|
|||||||
'id', 'name', 'display_name', 'device_type', 'device_role', 'tenant', 'platform', 'serial', 'asset_tag',
|
'id', 'name', 'display_name', 'device_type', 'device_role', 'tenant', 'platform', 'serial', 'asset_tag',
|
||||||
'site', 'rack', 'position', 'face', 'parent_device', 'status', 'primary_ip', 'primary_ip4', 'primary_ip6',
|
'site', 'rack', 'position', 'face', 'parent_device', 'status', 'primary_ip', 'primary_ip4', 'primary_ip6',
|
||||||
'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'tags', 'custom_fields', 'created',
|
'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'tags', 'custom_fields', 'created',
|
||||||
'last_updated', 'local_config_context_data',
|
'last_updated', 'local_context_data',
|
||||||
]
|
]
|
||||||
validators = []
|
validators = []
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ class DeviceWithConfigContextSerializer(DeviceSerializer):
|
|||||||
'id', 'name', 'display_name', 'device_type', 'device_role', 'tenant', 'platform', 'serial', 'asset_tag',
|
'id', 'name', 'display_name', 'device_type', 'device_role', 'tenant', 'platform', 'serial', 'asset_tag',
|
||||||
'site', 'rack', 'position', 'face', 'parent_device', 'status', 'primary_ip', 'primary_ip4', 'primary_ip6',
|
'site', 'rack', 'position', 'face', 'parent_device', 'status', 'primary_ip', 'primary_ip4', 'primary_ip6',
|
||||||
'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'tags', 'custom_fields',
|
'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'tags', 'custom_fields',
|
||||||
'config_context', 'created', 'last_updated', 'local_config_context_data',
|
'config_context', 'created', 'last_updated', 'local_context_data',
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_config_context(self, obj):
|
def get_config_context(self, obj):
|
||||||
|
@ -823,16 +823,19 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldForm):
|
|||||||
)
|
)
|
||||||
comments = CommentField()
|
comments = CommentField()
|
||||||
tags = TagField(required=False)
|
tags = TagField(required=False)
|
||||||
|
local_context_data = JSONField(required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Device
|
model = Device
|
||||||
fields = [
|
fields = [
|
||||||
'name', 'device_role', 'device_type', 'serial', 'asset_tag', 'site', 'rack', 'position', 'face',
|
'name', 'device_role', 'device_type', 'serial', 'asset_tag', 'site', 'rack', 'position', 'face',
|
||||||
'status', 'platform', 'primary_ip4', 'primary_ip6', 'tenant_group', 'tenant', 'comments', 'tags',
|
'status', 'platform', 'primary_ip4', 'primary_ip6', 'tenant_group', 'tenant', 'comments', 'tags',
|
||||||
|
'local_context_data'
|
||||||
]
|
]
|
||||||
help_texts = {
|
help_texts = {
|
||||||
'device_role': "The function this device serves",
|
'device_role': "The function this device serves",
|
||||||
'serial': "Chassis serial number",
|
'serial': "Chassis serial number",
|
||||||
|
'local_context_data': "Local config context data overwrites all sources contexts in the final rendered config context"
|
||||||
}
|
}
|
||||||
widgets = {
|
widgets = {
|
||||||
'face': forms.Select(attrs={'filter-for': 'position'}),
|
'face': forms.Select(attrs={'filter-for': 'position'}),
|
||||||
@ -920,16 +923,6 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldForm):
|
|||||||
self.initial['rack'] = self.instance.parent_bay.device.rack_id
|
self.initial['rack'] = self.instance.parent_bay.device.rack_id
|
||||||
|
|
||||||
|
|
||||||
class DeviceLocalConfigContextForm(BootstrapMixin, forms.ModelForm):
|
|
||||||
local_config_context_data = JSONField()
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Device
|
|
||||||
fields = [
|
|
||||||
'local_config_context_data',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class BaseDeviceCSVForm(forms.ModelForm):
|
class BaseDeviceCSVForm(forms.ModelForm):
|
||||||
device_role = forms.ModelChoiceField(
|
device_role = forms.ModelChoiceField(
|
||||||
queryset=DeviceRole.objects.all(),
|
queryset=DeviceRole.objects.all(),
|
||||||
|
@ -13,7 +13,7 @@ class Migration(migrations.Migration):
|
|||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='device',
|
model_name='device',
|
||||||
name='local_config_context_data',
|
name='local_context_data',
|
||||||
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True),
|
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True),
|
||||||
),
|
),
|
||||||
]
|
]
|
@ -1287,10 +1287,6 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
|
|||||||
images = GenericRelation(
|
images = GenericRelation(
|
||||||
to='extras.ImageAttachment'
|
to='extras.ImageAttachment'
|
||||||
)
|
)
|
||||||
local_config_context_data = JSONField(
|
|
||||||
blank=True,
|
|
||||||
null=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
objects = DeviceManager()
|
objects = DeviceManager()
|
||||||
tags = TaggableManager()
|
tags = TaggableManager()
|
||||||
|
@ -142,8 +142,6 @@ urlpatterns = [
|
|||||||
url(r'^devices/(?P<pk>\d+)/edit/$', views.DeviceEditView.as_view(), name='device_edit'),
|
url(r'^devices/(?P<pk>\d+)/edit/$', views.DeviceEditView.as_view(), name='device_edit'),
|
||||||
url(r'^devices/(?P<pk>\d+)/delete/$', views.DeviceDeleteView.as_view(), name='device_delete'),
|
url(r'^devices/(?P<pk>\d+)/delete/$', views.DeviceDeleteView.as_view(), name='device_delete'),
|
||||||
url(r'^devices/(?P<pk>\d+)/config-context/$', views.DeviceConfigContextView.as_view(), name='device_configcontext'),
|
url(r'^devices/(?P<pk>\d+)/config-context/$', views.DeviceConfigContextView.as_view(), name='device_configcontext'),
|
||||||
url(r'^devices/(?P<pk>\d+)/config-context/edit-local/$', views.DeviceEditLocalConfigContextView.as_view(), name='device_edit_localconfigcontext'),
|
|
||||||
url(r'^devices/(?P<pk>\d+)/config-context/clear-local/$', views.DeviceClearLocalContextDataView.as_view(), name='device_delete_localconfigcontext'),
|
|
||||||
url(r'^devices/(?P<pk>\d+)/changelog/$', ObjectChangeLogView.as_view(), name='device_changelog', kwargs={'model': Device}),
|
url(r'^devices/(?P<pk>\d+)/changelog/$', ObjectChangeLogView.as_view(), name='device_changelog', kwargs={'model': Device}),
|
||||||
url(r'^devices/(?P<pk>\d+)/inventory/$', views.DeviceInventoryView.as_view(), name='device_inventory'),
|
url(r'^devices/(?P<pk>\d+)/inventory/$', views.DeviceInventoryView.as_view(), name='device_inventory'),
|
||||||
url(r'^devices/(?P<pk>\d+)/status/$', views.DeviceStatusView.as_view(), name='device_status'),
|
url(r'^devices/(?P<pk>\d+)/status/$', views.DeviceStatusView.as_view(), name='device_status'),
|
||||||
|
@ -26,7 +26,7 @@ from utilities.forms import ConfirmationForm
|
|||||||
from utilities.paginator import EnhancedPaginator
|
from utilities.paginator import EnhancedPaginator
|
||||||
from utilities.views import (
|
from utilities.views import (
|
||||||
BulkComponentCreateView, BulkDeleteView, BulkEditView, BulkImportView, ComponentCreateView, GetReturnURLMixin,
|
BulkComponentCreateView, BulkDeleteView, BulkEditView, BulkImportView, ComponentCreateView, GetReturnURLMixin,
|
||||||
ObjectDeleteView, ObjectEditView, ObjectListView, ObjectSetFieldNullView,
|
ObjectDeleteView, ObjectEditView, ObjectListView,
|
||||||
)
|
)
|
||||||
from virtualization.models import VirtualMachine
|
from virtualization.models import VirtualMachine
|
||||||
from . import filters, forms, tables
|
from . import filters, forms, tables
|
||||||
@ -983,19 +983,6 @@ class DeviceEditView(DeviceCreateView):
|
|||||||
permission_required = 'dcim.change_device'
|
permission_required = 'dcim.change_device'
|
||||||
|
|
||||||
|
|
||||||
class DeviceEditLocalConfigContextView(DeviceCreateView):
|
|
||||||
permission_required = 'dcim.change_device'
|
|
||||||
model_form = forms.DeviceLocalConfigContextForm
|
|
||||||
template_name = 'dcim/device_edit_local_config_context.html'
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceClearLocalContextDataView(ObjectSetFieldNullView):
|
|
||||||
permission_required = 'dcim.change_device'
|
|
||||||
model = Device
|
|
||||||
field = 'local_config_context_data'
|
|
||||||
field_human_friendly_name = 'local config context'
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceDeleteView(PermissionRequiredMixin, ObjectDeleteView):
|
class DeviceDeleteView(PermissionRequiredMixin, ObjectDeleteView):
|
||||||
permission_required = 'dcim.delete_device'
|
permission_required = 'dcim.delete_device'
|
||||||
model = Device
|
model = Device
|
||||||
|
@ -703,6 +703,11 @@ class ConfigContext(models.Model):
|
|||||||
|
|
||||||
class ConfigContextModel(models.Model):
|
class ConfigContextModel(models.Model):
|
||||||
|
|
||||||
|
local_context_data = JSONField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
@ -717,8 +722,8 @@ class ConfigContextModel(models.Model):
|
|||||||
data.update(context.data)
|
data.update(context.data)
|
||||||
|
|
||||||
# If the object has local config context data defined, that data overwrites all rendered data
|
# If the object has local config context data defined, that data overwrites all rendered data
|
||||||
if self.local_config_context_data is not None:
|
if self.local_context_data is not None:
|
||||||
data.update(self.local_config_context_data)
|
data.update(self.local_context_data)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -107,14 +107,10 @@ class ObjectConfigContextView(View):
|
|||||||
obj = get_object_or_404(self.object_class, pk=pk)
|
obj = get_object_or_404(self.object_class, pk=pk)
|
||||||
source_contexts = ConfigContext.objects.get_for_object(obj)
|
source_contexts = ConfigContext.objects.get_for_object(obj)
|
||||||
model_name = self.object_class._meta.model_name
|
model_name = self.object_class._meta.model_name
|
||||||
app_label = self.object_class._meta.app_label
|
|
||||||
|
|
||||||
return render(request, 'extras/object_configcontext.html', {
|
return render(request, 'extras/object_configcontext.html', {
|
||||||
model_name: obj,
|
model_name: obj,
|
||||||
'obj': obj,
|
'obj': obj,
|
||||||
'perm_string': '{}.change_{}'.format(app_label, model_name),
|
|
||||||
'edit_url': '{}:{}_edit_localconfigcontext'.format(app_label, model_name),
|
|
||||||
'delete_url': '{}:{}_delete_localconfigcontext'.format(app_label, model_name),
|
|
||||||
'rendered_context': obj.get_config_context(),
|
'rendered_context': obj.get_config_context(),
|
||||||
'source_contexts': source_contexts,
|
'source_contexts': source_contexts,
|
||||||
'base_template': self.base_template,
|
'base_template': self.base_template,
|
||||||
|
@ -77,6 +77,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading"><strong>Local Config Context Data</strong></div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{% render_field form.local_context_data %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading"><strong>Tags</strong></div>
|
<div class="panel-heading"><strong>Tags</strong></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@ -21,32 +21,18 @@
|
|||||||
<strong>Local Context</strong>
|
<strong>Local Context</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{% if obj.local_config_context_data %}
|
{% if obj.local_context_data %}
|
||||||
<pre>{{ obj.local_config_context_data|render_json }}</pre>
|
<pre>{{ obj.local_context_data|render_json }}</pre>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="text-muted">None</span>
|
<span class="text-muted">None</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="panel-footer">
|
||||||
<span class="help-block">
|
<span class="help-block">
|
||||||
<i class="fa fa-info-circle"></i>
|
<i class="fa fa-info-circle"></i>
|
||||||
The local config context overwrites all source contexts.
|
The local config context overwrites all source contexts.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer">
|
|
||||||
{% if perm_string in perms %}
|
|
||||||
{% if obj.local_config_context_data %}
|
|
||||||
<a href="{% url edit_url pk=obj.pk %}?return_url={{ obj.get_absolute_url }}config-context/" class="btn btn-warning btn-xs">
|
|
||||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Edit
|
|
||||||
</a>
|
|
||||||
<a href="{% url delete_url pk=obj.pk %}?return_url={{ obj.get_absolute_url }}config-context/" class="btn btn-danger btn-xs">
|
|
||||||
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
|
|
||||||
</a>
|
|
||||||
{% else %}
|
|
||||||
<a href="{% url edit_url pk=obj.pk %}?return_url={{ obj.get_absolute_url }}config-context/" class="btn btn-success btn-xs">
|
|
||||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add local context
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
|
@ -48,6 +48,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading"><strong>Local Config Context Data</strong></div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{% render_field form.local_context_data %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading"><strong>Tags</strong></div>
|
<div class="panel-heading"><strong>Tags</strong></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@ -844,56 +844,6 @@ class BulkComponentCreateView(GetReturnURLMixin, View):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class ObjectSetFieldNullView(ObjectDeleteView):
|
|
||||||
"""
|
|
||||||
Given a field name, set it to None (null) and save the object.
|
|
||||||
|
|
||||||
field: The field to be nulled
|
|
||||||
field_friendly_name: Human friendly name for the field in the UI.
|
|
||||||
"""
|
|
||||||
template_name = 'utilities/object_set_field_null.html'
|
|
||||||
field_human_friendly_name = None
|
|
||||||
|
|
||||||
def get(self, request, **kwargs):
|
|
||||||
|
|
||||||
obj = self.get_object(kwargs)
|
|
||||||
form = ConfirmationForm(initial=request.GET)
|
|
||||||
|
|
||||||
return render(request, self.template_name, {
|
|
||||||
'obj': obj,
|
|
||||||
'form': form,
|
|
||||||
'obj_type': self.model._meta.verbose_name,
|
|
||||||
'field_human_friendly_name': self.field_human_friendly_name,
|
|
||||||
'return_url': self.get_return_url(request, obj),
|
|
||||||
})
|
|
||||||
|
|
||||||
def post(self, request, **kwargs):
|
|
||||||
|
|
||||||
obj = self.get_object(kwargs)
|
|
||||||
form = ConfirmationForm(request.POST)
|
|
||||||
if form.is_valid():
|
|
||||||
|
|
||||||
setattr(obj, self.field, None)
|
|
||||||
obj.save()
|
|
||||||
|
|
||||||
msg = 'Cleared {} on {} {}'.format(self.field_human_friendly_name, self.model._meta.verbose_name, obj)
|
|
||||||
messages.success(request, msg)
|
|
||||||
|
|
||||||
return_url = form.cleaned_data.get('return_url')
|
|
||||||
if return_url is not None and is_safe_url(url=return_url, host=request.get_host()):
|
|
||||||
return redirect(return_url)
|
|
||||||
else:
|
|
||||||
return redirect(self.get_return_url(request, obj))
|
|
||||||
|
|
||||||
return render(request, self.template_name, {
|
|
||||||
'obj': obj,
|
|
||||||
'form': form,
|
|
||||||
'obj_type': self.model._meta.verbose_name,
|
|
||||||
'field_human_friendly_name': self.field_human_friendly_name,
|
|
||||||
'return_url': self.get_return_url(request, obj),
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@requires_csrf_token
|
@requires_csrf_token
|
||||||
def server_error(request, template_name=ERROR_500_TEMPLATE_NAME):
|
def server_error(request, template_name=ERROR_500_TEMPLATE_NAME):
|
||||||
"""
|
"""
|
||||||
|
@ -107,7 +107,7 @@ class VirtualMachineSerializer(TaggitSerializer, CustomFieldModelSerializer):
|
|||||||
fields = [
|
fields = [
|
||||||
'id', 'name', 'status', 'site', 'cluster', 'role', 'tenant', 'platform', 'primary_ip', 'primary_ip4',
|
'id', 'name', 'status', 'site', 'cluster', 'role', 'tenant', 'platform', 'primary_ip', 'primary_ip4',
|
||||||
'primary_ip6', 'vcpus', 'memory', 'disk', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
|
'primary_ip6', 'vcpus', 'memory', 'disk', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
|
||||||
'local_config_context_data',
|
'local_context_data',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class VirtualMachineWithConfigContextSerializer(VirtualMachineSerializer):
|
|||||||
fields = [
|
fields = [
|
||||||
'id', 'name', 'status', 'cluster', 'role', 'tenant', 'platform', 'primary_ip', 'primary_ip4', 'primary_ip6',
|
'id', 'name', 'status', 'cluster', 'role', 'tenant', 'platform', 'primary_ip', 'primary_ip4', 'primary_ip6',
|
||||||
'vcpus', 'memory', 'disk', 'comments', 'tags', 'custom_fields', 'config_context', 'created', 'last_updated',
|
'vcpus', 'memory', 'disk', 'comments', 'tags', 'custom_fields', 'config_context', 'created', 'last_updated',
|
||||||
'local_config_context_data',
|
'local_context_data',
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_config_context(self, obj):
|
def get_config_context(self, obj):
|
||||||
|
@ -248,6 +248,7 @@ class VirtualMachineForm(BootstrapMixin, TenancyForm, CustomFieldForm):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
tags = TagField(required=False)
|
tags = TagField(required=False)
|
||||||
|
local_context_data = JSONField(required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VirtualMachine
|
model = VirtualMachine
|
||||||
@ -255,6 +256,9 @@ class VirtualMachineForm(BootstrapMixin, TenancyForm, CustomFieldForm):
|
|||||||
'name', 'status', 'cluster_group', 'cluster', 'role', 'tenant', 'platform', 'primary_ip4', 'primary_ip6',
|
'name', 'status', 'cluster_group', 'cluster', 'role', 'tenant', 'platform', 'primary_ip4', 'primary_ip6',
|
||||||
'vcpus', 'memory', 'disk', 'comments', 'tags',
|
'vcpus', 'memory', 'disk', 'comments', 'tags',
|
||||||
]
|
]
|
||||||
|
help_texts = {
|
||||||
|
'local_context_data': "Local config context data overwrites all sources contexts in the final rendered config context",
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
@ -303,16 +307,6 @@ class VirtualMachineForm(BootstrapMixin, TenancyForm, CustomFieldForm):
|
|||||||
self.fields['primary_ip6'].widget.attrs['readonly'] = True
|
self.fields['primary_ip6'].widget.attrs['readonly'] = True
|
||||||
|
|
||||||
|
|
||||||
class VirtualMachineLocalConfigContextForm(BootstrapMixin, forms.ModelForm):
|
|
||||||
local_config_context_data = JSONField()
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = VirtualMachine
|
|
||||||
fields = [
|
|
||||||
'local_config_context_data',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class VirtualMachineCSVForm(forms.ModelForm):
|
class VirtualMachineCSVForm(forms.ModelForm):
|
||||||
status = CSVChoiceField(
|
status = CSVChoiceField(
|
||||||
choices=VM_STATUS_CHOICES,
|
choices=VM_STATUS_CHOICES,
|
||||||
|
@ -13,7 +13,7 @@ class Migration(migrations.Migration):
|
|||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='virtualmachine',
|
model_name='virtualmachine',
|
||||||
name='local_config_context_data',
|
name='local_context_data',
|
||||||
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True),
|
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True),
|
||||||
),
|
),
|
||||||
]
|
]
|
@ -245,10 +245,6 @@ class VirtualMachine(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
|
|||||||
content_type_field='obj_type',
|
content_type_field='obj_type',
|
||||||
object_id_field='obj_id'
|
object_id_field='obj_id'
|
||||||
)
|
)
|
||||||
local_config_context_data = JSONField(
|
|
||||||
blank=True,
|
|
||||||
null=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
tags = TaggableManager()
|
tags = TaggableManager()
|
||||||
|
|
||||||
|
@ -49,8 +49,6 @@ urlpatterns = [
|
|||||||
url(r'^virtual-machines/(?P<pk>\d+)/edit/$', views.VirtualMachineEditView.as_view(), name='virtualmachine_edit'),
|
url(r'^virtual-machines/(?P<pk>\d+)/edit/$', views.VirtualMachineEditView.as_view(), name='virtualmachine_edit'),
|
||||||
url(r'^virtual-machines/(?P<pk>\d+)/delete/$', views.VirtualMachineDeleteView.as_view(), name='virtualmachine_delete'),
|
url(r'^virtual-machines/(?P<pk>\d+)/delete/$', views.VirtualMachineDeleteView.as_view(), name='virtualmachine_delete'),
|
||||||
url(r'^virtual-machines/(?P<pk>\d+)/config-context/$', views.VirtualMachineConfigContextView.as_view(), name='virtualmachine_configcontext'),
|
url(r'^virtual-machines/(?P<pk>\d+)/config-context/$', views.VirtualMachineConfigContextView.as_view(), name='virtualmachine_configcontext'),
|
||||||
url(r'^virtual-machines/(?P<pk>\d+)/config-context/edit-local/$', views.VirtualMachineEditLocalConfigContextView.as_view(), name='virtualmachine_edit_localconfigcontext'),
|
|
||||||
url(r'^virtual-machines/(?P<pk>\d+)/config-context/clear-local/$', views.VirtualMachineClearLocalContextDataView.as_view(), name='virtualmachine_delete_localconfigcontext'),
|
|
||||||
url(r'^virtual-machines/(?P<pk>\d+)/changelog/$', ObjectChangeLogView.as_view(), name='virtualmachine_changelog', kwargs={'model': VirtualMachine}),
|
url(r'^virtual-machines/(?P<pk>\d+)/changelog/$', ObjectChangeLogView.as_view(), name='virtualmachine_changelog', kwargs={'model': VirtualMachine}),
|
||||||
url(r'^virtual-machines/(?P<virtualmachine>\d+)/services/assign/$', ServiceCreateView.as_view(), name='virtualmachine_service_assign'),
|
url(r'^virtual-machines/(?P<virtualmachine>\d+)/services/assign/$', ServiceCreateView.as_view(), name='virtualmachine_service_assign'),
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from extras.views import ObjectConfigContextView
|
|||||||
from ipam.models import Service
|
from ipam.models import Service
|
||||||
from utilities.views import (
|
from utilities.views import (
|
||||||
BulkComponentCreateView, BulkDeleteView, BulkEditView, BulkImportView, ComponentCreateView, ObjectDeleteView,
|
BulkComponentCreateView, BulkDeleteView, BulkEditView, BulkImportView, ComponentCreateView, ObjectDeleteView,
|
||||||
ObjectEditView, ObjectListView, ObjectSetFieldNullView,
|
ObjectEditView, ObjectListView,
|
||||||
)
|
)
|
||||||
from . import filters, forms, tables
|
from . import filters, forms, tables
|
||||||
from .models import Cluster, ClusterGroup, ClusterType, VirtualMachine
|
from .models import Cluster, ClusterGroup, ClusterType, VirtualMachine
|
||||||
@ -285,19 +285,6 @@ class VirtualMachineCreateView(PermissionRequiredMixin, ObjectEditView):
|
|||||||
default_return_url = 'virtualization:virtualmachine_list'
|
default_return_url = 'virtualization:virtualmachine_list'
|
||||||
|
|
||||||
|
|
||||||
class VirtualMachineEditLocalConfigContextView(VirtualMachineCreateView):
|
|
||||||
permission_required = 'virtualization.change_device'
|
|
||||||
model_form = forms.VirtualMachineLocalConfigContextForm
|
|
||||||
template_name = 'virtualization/virtualmachine_edit_local_config_context.html'
|
|
||||||
|
|
||||||
|
|
||||||
class VirtualMachineClearLocalContextDataView(ObjectSetFieldNullView):
|
|
||||||
permission_required = 'virtualization.change_virtualmachine'
|
|
||||||
model = VirtualMachine
|
|
||||||
field = 'local_config_context_data'
|
|
||||||
field_human_friendly_name = 'local config context'
|
|
||||||
|
|
||||||
|
|
||||||
class VirtualMachineEditView(VirtualMachineCreateView):
|
class VirtualMachineEditView(VirtualMachineCreateView):
|
||||||
permission_required = 'virtualization.change_virtualmachine'
|
permission_required = 'virtualization.change_virtualmachine'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user