-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
135 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
FROM mcr.microsoft.com/devcontainers/python:3 | ||
|
||
|
||
|
||
# Run the commands in the Dockerfile | ||
RUN python -m pip install --upgrade pip \ | ||
&& python -m pip install 'flit>=3.8.0' | ||
|
||
ENV FLIT_ROOT_INSTALL=1 | ||
|
||
COPY pyproject.toml . | ||
RUN touch README.md \ | ||
&& mkdir -p src/python_package \ | ||
&& python -m flit install --only-deps --deps develop \ | ||
&& rm -r pyproject.toml README.md src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,3 +277,5 @@ dmypy.json | |
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
netbox-src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
__author__ = """Jamie Murphy""" | ||
__email__ = "[email protected]" | ||
__version__ = "0.2.1" | ||
__version__ = "0.3.0" | ||
|
||
|
||
from netbox.plugins import PluginConfig | ||
|
@@ -18,6 +18,10 @@ class ChangeLogDiffConfig(PluginConfig): | |
"change_log_format": "yaml", | ||
"hide_native_diff": False, | ||
} | ||
def ready(self): | ||
super().ready() | ||
from netbox_changelog_diff_plugin.tables import register_changelog | ||
register_changelog() | ||
|
||
|
||
config = ChangeLogDiffConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by Django 5.0.9 on 2024-11-04 22:09 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
("core", "0012_job_object_type_optional"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="ChangeLogSummary", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, primary_key=True, serialize=False | ||
), | ||
), | ||
("summary", models.TextField()), | ||
( | ||
"changelog", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="human_summary", | ||
to="core.objectchange", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "Changelog Summary", | ||
"verbose_name_plural": "Changelog Summaries", | ||
}, | ||
), | ||
] |
24 changes: 24 additions & 0 deletions
24
netbox_changelog_diff_plugin/migrations/0002_alter_changelogsummary_changelog.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 5.0.9 on 2024-11-04 23:19 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0012_job_object_type_optional"), | ||
("netbox_changelog_diff_plugin", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="changelogsummary", | ||
name="changelog", | ||
field=models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="human_summary", | ||
to="core.objectchange", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
from django.db import models | ||
from django.urls import reverse | ||
from netbox.models import NetBoxModel | ||
# from netbox.core.models import ObjectChange | ||
|
||
class ChangeLogSummary(NetBoxModel): | ||
|
||
class ChangeLogSummary(models.Model): | ||
"""Model to store human-readable summaries of changelogs""" | ||
changelog = models.ForeignKey( | ||
to='extras.ObjectChange', | ||
|
||
changelog = models.OneToOneField( | ||
to='core.ObjectChange', | ||
on_delete=models.CASCADE, | ||
related_name='summaries' | ||
related_name='human_summary', | ||
unique=True | ||
) | ||
|
||
summary = models.TextField( | ||
help_text="Human readable summary of the changes made" | ||
) | ||
|
||
class Meta: | ||
verbose_name = "Changelog Summary" | ||
verbose_name_plural = "Changelog Summaries" | ||
ordering = ['-changelog__time'] | ||
# ordering = ['-id'] | ||
|
||
def __str__(self): | ||
return f"Summary for change {self.changelog.id}" | ||
return f"{self.summary}" | ||
|
||
def get_absolute_url(self): | ||
return reverse('plugins:netbox_changelog_diff_plugin:changelogsummary', args=[self.pk]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
import django_tables2 as tables | ||
from netbox.tables import NetBoxTable, ChoiceFieldColumn | ||
import django_tables2 | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from .models import ChangeLogSummary | ||
from core.tables.change_logging import ObjectChangeTable | ||
from utilities.tables import register_table_column | ||
|
||
mycol_2 = django_tables2.Column( | ||
verbose_name=_('Change Summary'), | ||
accessor=django_tables2.A('human_summary'), | ||
default="- -" | ||
) | ||
|
||
def register_changelog(): | ||
register_table_column(mycol_2, 'human_summary', ObjectChangeTable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "netbox-changelog-diff-plugin" | ||
version = "0.2.1" | ||
version = "0.3.0" | ||
authors = [ | ||
{name = "Jamie Murphy", email = "[email protected]"}, | ||
] | ||
|