Coverage for backend/core/auxiliary/models/ProcessPath.py: 76%

17 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-11-06 23:27 +0000

1from django.db import models 

2 

3from flowsheetInternals.unitops.models import SimulationObject 

4from core.managers import AccessControlManager 

5class ProcessPath(models.Model): 

6 flowsheet = models.ForeignKey("Flowsheet", on_delete=models.CASCADE, related_name="ProcessPaths") 

7 highlight = models.BooleanField(default=False, blank=True) 

8 pathwayObjects = models.ManyToManyField(SimulationObject, related_name="ProcessPath") 

9 

10 created_at = models.DateTimeField(auto_now_add=True) 

11 objects = AccessControlManager() 

12 

13 

14 

15 class Meta: 

16 ordering = ['created_at'] 

17 

18 

19 @classmethod 

20 def create(cls, flowsheet: "Flowsheet", pathwayObjects: list[SimulationObject]) -> "ProcessPath": 

21 processPath = ProcessPath(flowsheet=flowsheet) 

22 processPath.save() 

23 processPath.pathwayObjects.set(pathwayObjects) 

24 

25 return processPath