Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make deletion of scenarios possible #348

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions backend/src/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __str__(self):


class ScenarioParameterGroup(models.Model):
distribution = models.ForeignKey(Distribution, related_name='distribution', on_delete=models.RESTRICT)
distribution = models.ForeignKey(Distribution, related_name='distribution', on_delete=models.CASCADE)
groups = models.ManyToManyField(Group)

@property
Expand All @@ -176,7 +176,7 @@ def max(self):

class ScenarioParameter(models.Model):
"""Model definition for a parameter belonging to a scenario."""
parameter = models.ForeignKey(Parameter, related_name='parameter', on_delete=models.RESTRICT)
parameter = models.ForeignKey(Parameter, related_name='parameter', on_delete=models.CASCADE)
groups = models.ManyToManyField(ScenarioParameterGroup)

class Meta:
Expand All @@ -190,7 +190,7 @@ class ScenarioNode(models.Model):
"""Model definition for a node belonging to a scenario (i.e. counties)."""

# Fields
node = models.ForeignKey(Node, on_delete=models.RESTRICT)
node = models.ForeignKey(Node, on_delete=models.CASCADE)
parameters = models.ManyToManyField(ScenarioParameter)
interventions = models.ManyToManyField(Intervention)

Expand Down Expand Up @@ -219,7 +219,7 @@ class Scenario(models.Model):
key = models.CharField(max_length=20, unique=True)
name = models.CharField(max_length=100)
description = models.TextField()
simulation_model = models.ForeignKey(SimulationModel, related_name='simulation_model', on_delete=models.RESTRICT)
simulation_model = models.ForeignKey(SimulationModel, related_name='simulation_model', on_delete=models.CASCADE)
number_of_groups = models.IntegerField()
number_of_nodes = models.IntegerField()
nodes = models.ManyToManyField(ScenarioNode)
Expand Down Expand Up @@ -248,7 +248,7 @@ def delete(self, *args, **kwargs):

class SimulationCompartment(Distribution):
"""Model definition for a compartment belonging to a simulation."""
compartment = models.ForeignKey(Compartment, on_delete=models.RESTRICT)
compartment = models.ForeignKey(Compartment, on_delete=models.CASCADE)

class Meta:
pass
Expand All @@ -260,7 +260,7 @@ def __str__(self):
class SimulationNode(models.Model):
"""Model definition for a node belonging to a simulation (i.e. counties)."""

scenario_node = models.ForeignKey(ScenarioNode, on_delete=models.RESTRICT)
scenario_node = models.ForeignKey(ScenarioNode, on_delete=models.CASCADE)
data = models.ManyToManyField(DataEntry)

class Meta:
Expand All @@ -284,7 +284,7 @@ class Simulation(models.Model):
start_day = models.DateField()
number_of_days = models.IntegerField()

scenario = models.ForeignKey(Scenario, on_delete=models.RESTRICT)
scenario = models.ForeignKey(Scenario, on_delete=models.CASCADE)
nodes = models.ManyToManyField(SimulationNode)

class Meta:
Expand Down
Loading