Add inheritance model
This commit is contained in:
parent
90dcf7a8eb
commit
ecb26c3908
28
rsconcept/backend/apps/oss/migrations/0002_inheritance.py
Normal file
28
rsconcept/backend/apps/oss/migrations/0002_inheritance.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 5.0.7 on 2024-07-25 18:08
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('oss', '0001_initial'),
|
||||||
|
('rsform', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Inheritance',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='as_child', to='rsform.constituenta', verbose_name='Наследованная конституента')),
|
||||||
|
('parent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='as_parent', to='rsform.constituenta', verbose_name='Исходная конституента')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Наследование синтеза',
|
||||||
|
'verbose_name_plural': 'Отношение наследования конституент',
|
||||||
|
'unique_together': {('parent', 'child')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
|
@ -4,12 +4,6 @@ from django.db.models import CASCADE, ForeignKey, Model
|
||||||
|
|
||||||
class Inheritance(Model):
|
class Inheritance(Model):
|
||||||
''' Inheritance links parent and child constituents in synthesis operation.'''
|
''' Inheritance links parent and child constituents in synthesis operation.'''
|
||||||
operation: ForeignKey = ForeignKey(
|
|
||||||
verbose_name='Операция',
|
|
||||||
to='oss.Operation',
|
|
||||||
on_delete=CASCADE
|
|
||||||
)
|
|
||||||
|
|
||||||
parent: ForeignKey = ForeignKey(
|
parent: ForeignKey = ForeignKey(
|
||||||
verbose_name='Исходная конституента',
|
verbose_name='Исходная конституента',
|
||||||
to='rsform.Constituenta',
|
to='rsform.Constituenta',
|
||||||
|
@ -27,6 +21,8 @@ class Inheritance(Model):
|
||||||
''' Model metadata. '''
|
''' Model metadata. '''
|
||||||
verbose_name = 'Наследование синтеза'
|
verbose_name = 'Наследование синтеза'
|
||||||
verbose_name_plural = 'Отношение наследования конституент'
|
verbose_name_plural = 'Отношение наследования конституент'
|
||||||
|
unique_together = [['parent', 'child']]
|
||||||
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f'{self.parent} -> {self.child}'
|
return f'{self.parent} -> {self.child}'
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
''' Django: Models. '''
|
''' Django: Models. '''
|
||||||
|
|
||||||
from .Argument import Argument
|
from .Argument import Argument
|
||||||
|
from .Inheritance import Inheritance
|
||||||
from .Operation import Operation, OperationType
|
from .Operation import Operation, OperationType
|
||||||
from .OperationSchema import OperationSchema
|
from .OperationSchema import OperationSchema
|
||||||
from .Substitution import Substitution
|
from .Substitution import Substitution
|
||||||
|
|
Loading…
Reference in New Issue
Block a user