feat(itam): Device Model Notes Model

ref: #523 #526
This commit is contained in:
2025-02-07 21:31:09 +09:30
parent e8ce851c31
commit e18f70a20c
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# Generated by Django 5.1.5 on 2025-02-07 12:00
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0015_manufacturernotes'),
('itam', '0012_devicetypenotes'),
]
operations = [
migrations.CreateModel(
name='DeviceModelNotes',
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='itam.devicemodel', verbose_name='Model')),
],
options={
'verbose_name': 'Device Model Note',
'verbose_name_plural': 'Device Model Notes',
'db_table': 'itam_device_mdel_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 itam.models.device import DeviceModel
class DeviceModelNotes(
ModelNotes
):
class Meta:
db_table = 'itam_device_mdel_notes'
ordering = ModelNotes._meta.ordering
verbose_name = 'Device Model Note'
verbose_name_plural = 'Device Model Notes'
model = models.ForeignKey(
DeviceModel,
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
}