Coverage for backend/django/flowsheetInternals/propertyPackages/models/SimulationObjectPropertyPackages.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2026-03-26 20:57 +0000

1from django.db import models 

2from typing import TYPE_CHECKING 

3 

4from core.managers import AccessControlManager 

5 

6if TYPE_CHECKING: 

7 from core.auxiliary.models.Flowsheet import Flowsheet 

8 from core.auxiliary.models.CustomPropertyPackage import CustomPropertyPackage 

9 from flowsheetInternals.unitops.models.SimulationObject import SimulationObject 

10 

11 

12class SimulationObjectPropertyPackages(models.Model): 

13 """ 

14 Model stores the connections between simulation objects and property packages 

15 

16 Simulation objects have a many-to-many relationship with property packages. This relationship 

17 also needs a name to identify the property package in the simulation object. 

18 """ 

19 

20 flowsheet = models.ForeignKey("core_auxiliary.Flowsheet", on_delete=models.CASCADE, related_name="PropertyPackages") 

21 simulationObject = models.ForeignKey("flowsheetInternals_unitops.SimulationObject", on_delete=models.CASCADE, 

22 related_name='propertyPackages', null=True) 

23 propertyPackage = models.CharField(max_length=64, 

24 default="") # currently selected property package name, e.g helmholtz 

25 name = models.CharField(max_length=64, default="") # display name, e.g "hot side" 

26 customPackage = models.ForeignKey["CustomPropertyPackage"]("core_auxiliary.CustomPropertyPackage", on_delete=models.SET_NULL, null=True, blank=True, related_name="simulationObjectPropertyPackages") 

27 

28 created_at = models.DateTimeField(auto_now_add=True) 

29 

30 objects = AccessControlManager() 

31 

32 # runtime-accessed attributes 

33 flowsheet: "Flowsheet" 

34 simulationObject: "SimulationObject | None" 

35 

36 class Meta: 

37 ordering = ['created_at']