feat(config_management): Config Group Notes Model

ref: #526 #529
This commit is contained in:
2025-02-07 19:05:57 +09:30
parent 4367878396
commit c8f0c54549
4 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# Generated by Django 5.1.5 on 2025-02-07 09:32
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('config_management', '0005_alter_configgrouphosts_organization_and_more'),
('core', '0013_alter_manufacturer_organization_and_more'),
]
operations = [
migrations.CreateModel(
name='ConfigGroupNotes',
fields=[
('modelnotes_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.modelnotes')),
('model', models.ForeignKey(help_text='Model this note belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='config_management.configgroups', verbose_name='Model')),
],
options={
'verbose_name': 'Config Group Note',
'verbose_name_plural': 'Config Group Notes',
'db_table': 'config_management_config_group_notes',
'ordering': ['-created'],
},
bases=('core.modelnotes',),
),
]

View File

@ -0,0 +1,45 @@
from django.db import models
from core.models.model_notes import ModelNotes
from config_management.models.groups import ConfigGroups
class ConfigGroupNotes(
ModelNotes
):
class Meta:
db_table = 'config_management_config_group_notes'
ordering = ModelNotes._meta.ordering
verbose_name = 'Config Group Note'
verbose_name_plural = 'Config Group Notes'
model = models.ForeignKey(
ConfigGroups,
blank = False,
help_text = 'Model this note belongs to',
null = False,
on_delete = models.CASCADE,
related_name = 'notes',
verbose_name = 'Model',
)
table_fields: list = []
page_layout: dict = []
def get_url_kwargs(self) -> dict:
return {
'model_id': self.model.pk,
'pk': self.pk
}