feat(itim): Cluster Notes Model

ref: #526 #533
This commit is contained in:
2025-02-07 19:59:05 +09:30
parent 0b418b6f2c
commit ea8a56322f
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 10:28
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0015_manufacturernotes'),
('itim', '0006_alter_cluster_organization_and_more'),
]
operations = [
migrations.CreateModel(
name='ClusterNotes',
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='itim.cluster', verbose_name='Model')),
],
options={
'verbose_name': 'Cluster Note',
'verbose_name_plural': 'Cluster Notes',
'db_table': 'itim_cluster_notes',
'ordering': ['-created'],
},
bases=('core.modelnotes',),
),
]

View File

@ -0,0 +1,45 @@
from access.fields import *
from core.models.model_notes import ModelNotes
from itim.models.clusters import Cluster
class ClusterNotes(
ModelNotes
):
class Meta:
db_table = 'itim_cluster_notes'
ordering = ModelNotes._meta.ordering
verbose_name = 'Cluster Note'
verbose_name_plural = 'Cluster Notes'
model = models.ForeignKey(
Cluster,
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
}