1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #4840: Enable change logging for config contexts

This commit is contained in:
Jeremy Stretch
2020-07-09 17:09:03 -04:00
parent 8d7001fe56
commit 59091efa86
7 changed files with 39 additions and 3 deletions

View File

@ -26,6 +26,7 @@ When running a report or custom script, the task is now queued for background pr
* [#4807](https://github.com/netbox-community/netbox/issues/4807) - Add bulk edit ability for device bay templates
* [#4817](https://github.com/netbox-community/netbox/issues/4817) - Standardize device/VM component `name` field to 64 characters
* [#4837](https://github.com/netbox-community/netbox/issues/4837) - Use dynamic form widget for relationships to MPTT objects (e.g. regions)
* [#4840](https://github.com/netbox-community/netbox/issues/4840) - Enable change logging for config contexts
### Configuration Changes

View File

@ -233,7 +233,7 @@ class ConfigContextSerializer(ValidatedModelSerializer):
model = ConfigContext
fields = [
'id', 'url', 'name', 'weight', 'description', 'is_active', 'regions', 'sites', 'roles', 'platforms',
'cluster_groups', 'clusters', 'tenant_groups', 'tenants', 'tags', 'data',
'cluster_groups', 'clusters', 'tenant_groups', 'tenants', 'tags', 'data', 'created', 'last_updated',
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.6 on 2020-07-09 20:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('extras', '0044_jobresult'),
]
operations = [
migrations.AddField(
model_name='configcontext',
name='created',
field=models.DateField(auto_now_add=True, null=True),
),
migrations.AddField(
model_name='configcontext',
name='last_updated',
field=models.DateTimeField(auto_now=True, null=True),
),
]

View File

@ -434,7 +434,7 @@ class ImageAttachment(models.Model):
# Config contexts
#
class ConfigContext(models.Model):
class ConfigContext(ChangeLoggedModel):
"""
A ConfigContext represents a set of arbitrary data available to any Device or VirtualMachine matching its assigned
qualifiers (region, site, etc.). For example, the data stored in a ConfigContext assigned to site A and tenant B

View File

@ -45,6 +45,7 @@ class TagTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
# Blocked by absence of standard create/edit, bulk create views
class ConfigContextTestCase(
ViewTestCases.GetObjectViewTestCase,
ViewTestCases.GetObjectChangelogViewTestCase,
ViewTestCases.DeleteObjectViewTestCase,
ViewTestCases.ListObjectsViewTestCase,
ViewTestCases.BulkEditObjectsViewTestCase,

View File

@ -1,7 +1,7 @@
from django.urls import path
from extras import views
from extras.models import Tag
from extras.models import ConfigContext, Tag
app_name = 'extras'
@ -25,6 +25,7 @@ urlpatterns = [
path('config-contexts/<int:pk>/', views.ConfigContextView.as_view(), name='configcontext'),
path('config-contexts/<int:pk>/edit/', views.ConfigContextEditView.as_view(), name='configcontext_edit'),
path('config-contexts/<int:pk>/delete/', views.ConfigContextDeleteView.as_view(), name='configcontext_delete'),
path('config-contexts/<int:pk>/changelog/', views.ObjectChangeLogView.as_view(), name='configcontext_changelog', kwargs={'model': ConfigContext}),
# Image attachments
path('image-attachments/<int:pk>/edit/', views.ImageAttachmentEditView.as_view(), name='imageattachment_edit'),

View File

@ -31,6 +31,16 @@
</a>
{% endif %}
</div>
<ul class="nav nav-tabs">
<li role="presentation"{% if not active_tab %} class="active"{% endif %}>
<a href="{{ configcontext.get_absolute_url }}">Config Context</a>
</li>
{% if perms.extras.view_objectchange %}
<li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
<a href="{% url 'extras:configcontext_changelog' pk=configcontext.pk %}">Change Log</a>
</li>
{% endif %}
</ul>
<h1>{% block title %}{{ configcontext }}{% endblock %}</h1>
{% endblock %}