mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 21:10:38 +03:00
29 lines
961 B
Python
29 lines
961 B
Python
''' Models: Synthesis Inheritance. '''
|
|
from django.db.models import CASCADE, ForeignKey, Model
|
|
|
|
|
|
class Inheritance(Model):
|
|
''' Inheritance links parent and child constituents in synthesis operation.'''
|
|
parent: ForeignKey = ForeignKey(
|
|
verbose_name='Исходная конституента',
|
|
to='rsform.Constituenta',
|
|
on_delete=CASCADE,
|
|
related_name='as_parent'
|
|
)
|
|
child: ForeignKey = ForeignKey(
|
|
verbose_name='Наследованная конституента',
|
|
to='rsform.Constituenta',
|
|
on_delete=CASCADE,
|
|
related_name='as_child'
|
|
)
|
|
|
|
class Meta:
|
|
''' Model metadata. '''
|
|
verbose_name = 'Наследование синтеза'
|
|
verbose_name_plural = 'Отношение наследования конституент'
|
|
unique_together = [['parent', 'child']]
|
|
|
|
|
|
def __str__(self) -> str:
|
|
return f'{self.parent} -> {self.child}'
|