From 1db7c5ffeafd9fd1f3f0a9c9de6a9d0e456a4364 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 22 Mar 2023 23:29:12 +0000 Subject: [PATCH] change on_delete to cascade for blocks in a file --- core/models/survex.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/models/survex.py b/core/models/survex.py index 0e336ab..469628a 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -130,6 +130,7 @@ class SurvexBlockLookUpManager(models.Manager): class SurvexBlock(models.Model): """One begin..end block within a survex file. The basic element of a survey trip. Multiple anonymous survex blocks are possible within the same surfex file + Blocks can span several *included survexfile though. """ objects = SurvexBlockLookUpManager() # overwrites SurvexBlock.objects and enables lookup() @@ -139,8 +140,9 @@ class SurvexBlock(models.Model): date = models.DateField(blank=True, null=True) expedition = models.ForeignKey("Expedition", blank=True, null=True, on_delete=models.SET_NULL) - - survexfile = models.ForeignKey("SurvexFile", blank=True, null=True, on_delete=models.SET_NULL) + # if the survexfile object is deleted, then all teh suvex-blocks in it should be too, + # though a block can span more than one file... + survexfile = models.ForeignKey("SurvexFile", blank=True, null=True, on_delete=models.CASCADE) survexpath = models.CharField(max_length=200) # the path for the survex stations scanswallet = models.ForeignKey( @@ -209,7 +211,8 @@ class SingleScan(models.Model): class DrawingFile(models.Model): - """A file holding a Therion (several types) or a Tunnel drawing""" + """A file holding a Therion (several types) or a Tunnel drawing + Most of the implied capabilities are not implemented yet""" dwgpath = models.CharField(max_length=200) dwgname = models.CharField(max_length=200)