summaryrefslogtreecommitdiffstats
path: root/core/models_caves.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2020-06-30 15:26:03 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2020-06-30 15:26:03 +0100
commit6b0275d035669dd8514fbce96a606b19234ee3d2 (patch)
treee424c3e32c34315e68bcea1708ba4ee01ff58486 /core/models_caves.py
parentbe2b17ea8561f7b5678cbba5e5933c603b276dd9 (diff)
downloadtroggle-6b0275d035669dd8514fbce96a606b19234ee3d2.tar.gz
troggle-6b0275d035669dd8514fbce96a606b19234ee3d2.tar.bz2
troggle-6b0275d035669dd8514fbce96a606b19234ee3d2.zip
CASCADE on delete removed from key foregin keys
Diffstat (limited to 'core/models_caves.py')
-rw-r--r--core/models_caves.py36
1 files changed, 13 insertions, 23 deletions
diff --git a/core/models_caves.py b/core/models_caves.py
index 60a62a9..1f11c09 100644
--- a/core/models_caves.py
+++ b/core/models_caves.py
@@ -26,7 +26,7 @@ class Area(TroggleModel):
short_name = models.CharField(max_length=100)
name = models.CharField(max_length=200, blank=True, null=True)
description = models.TextField(blank=True,null=True)
- parent = models.ForeignKey('Area', blank=True, null=True,on_delete=models.CASCADE)
+ parent = models.ForeignKey('Area', blank=True, null=True,on_delete=models.SET_NULL)
def __str__(self):
if self.parent:
return str(self.parent) + " - " + str(self.short_name)
@@ -202,17 +202,6 @@ class Cave(TroggleModel):
pass
return lowestareas[0]
-# This seems to be peculiarly broken, and is now replaced for logbooks.
-# def getCaveByReference(reference):
- # areaname, code = reference.split("-", 1)
- # area = Area.objects.get(short_name = areaname)
- # foundCaves = list(Cave.objects.filter(area = area, kataster_number = code).all()) + list(Cave.objects.filter(area = area, unofficial_number = code).all())
- # #print((list(foundCaves)))
- # if len(foundCaves) == 1:
- # return foundCaves[0]
- # else:
- # return False
-
class OtherCaveName(TroggleModel):
name = models.CharField(max_length=160)
cave = models.ForeignKey(Cave,on_delete=models.CASCADE)
@@ -415,8 +404,8 @@ class LogbookEntry(TroggleModel):
)
date = models.DateField()#MJG wants to turn this into a datetime such that multiple Logbook entries on the same day can be ordered.ld()
- expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.CASCADE)#MJG wants to KILL THIS (redundant information)
- expedition = models.ForeignKey(Expedition,blank=True, null=True,on_delete=models.CASCADE) # yes this is double-
+ expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS (redundant information)
+ expedition = models.ForeignKey(Expedition,blank=True, null=True,on_delete=models.SET_NULL) # yes this is double-
title = models.CharField(max_length=settings.MAX_LOGBOOK_ENTRY_TITLE_LENGTH)
cave_slug = models.SlugField(max_length=50, blank=True, null=True)
place = models.CharField(max_length=100,blank=True, null=True,help_text="Only use this if you haven't chosen a cave")
@@ -488,10 +477,10 @@ class LogbookEntry(TroggleModel):
class QM(TroggleModel):
# based on qm.csv in trunk/expoweb/1623/204 which has the fields:
#"Number","Grade","Area","Description","Page reference","Nearest station","Completion description","Comment"
- found_by = models.ForeignKey(LogbookEntry, related_name='QMs_found',blank=True, null=True,on_delete=models.CASCADE )
- ticked_off_by = models.ForeignKey(LogbookEntry, related_name='QMs_ticked_off',blank=True, null=True,on_delete=models.CASCADE)
- #cave = models.ForeignKey(Cave,on_delete=models.CASCADE)
- #expedition = models.ForeignKey(Expedition,on_delete=models.CASCADE)
+ found_by = models.ForeignKey(LogbookEntry, related_name='QMs_found',blank=True, null=True,on_delete=models.SET_NULL )
+ ticked_off_by = models.ForeignKey(LogbookEntry, related_name='QMs_ticked_off',blank=True, null=True,on_delete=models.SET_NULL)
+ #cave = models.ForeignKey(Cave,on_delete=models.SET_NULL)
+ #expedition = models.ForeignKey(Expedition,on_delete=models.SET_NULL)
number = models.IntegerField(help_text="this is the sequential number in the year", )
GRADE_CHOICES=(
@@ -505,7 +494,7 @@ class QM(TroggleModel):
location_description = models.TextField(blank=True)
nearest_station_description = models.CharField(max_length=400,blank=True, null=True)
nearest_station_name = models.CharField(max_length=200,blank=True, null=True)
- nearest_station = models.ForeignKey(SurvexStation,blank=True, null=True,on_delete=models.CASCADE)
+ nearest_station = models.ForeignKey(SurvexStation,blank=True, null=True,on_delete=models.SET_NULL)
area = models.CharField(max_length=100,blank=True, null=True)
completion_description = models.TextField(blank=True,null=True)
comment=models.TextField(blank=True,null=True)
@@ -543,7 +532,7 @@ def get_scan_path(instance, filename):
class PersonTrip(TroggleModel):
personexpedition = models.ForeignKey("PersonExpedition",null=True,on_delete=models.CASCADE)
- #expeditionday = models.ForeignKey("ExpeditionDay",on_delete=models.CASCADE)#MJG wants to KILL THIS (redundant information)
+ #expeditionday = models.ForeignKey("ExpeditionDay",on_delete=models.SET_NULL)#MJG wants to KILL THIS (redundant information)
#date = models.DateField() #MJG wants to KILL THIS (redundant information)
time_underground = models.FloatField(help_text="In decimal hours")
logbook_entry = models.ForeignKey(LogbookEntry,on_delete=models.CASCADE)
@@ -552,9 +541,9 @@ class PersonTrip(TroggleModel):
# sequencing by person (difficult to solve locally)
#persontrip_next = models.ForeignKey('PersonTrip', related_name='pnext',
- #blank=True,null=True,on_delete=models.CASCADE)#MJG wants to KILL THIS (and use funstion persontrip_next_auto)
+ #blank=True,null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS (and use funstion persontrip_next_auto)
#persontrip_prev = models.ForeignKey('PersonTrip', related_name='pprev',
- #blank=True,null=True,on_delete=models.CASCADE)#MJG wants to KILL THIS(and use funstion persontrip_prev_auto)
+ #blank=True,null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS(and use funstion persontrip_prev_auto)
def persontrip_next(self):
futurePTs = PersonTrip.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__gt = self.logbook_entry.date).order_by('logbook_entry__date').all()
@@ -699,8 +688,10 @@ def GetCaveLookup():
Gcavelookup["2011-01-bs30"] = Gcavelookup["190"]
Gcavelookup["bs30"] = Gcavelookup["190"]
+ Gcavelookup["87"] = Gcavelookup["190"]
Gcavelookup["2011-01"] = Gcavelookup["190"]
+ Gcavelookup["quarriesd"] = Gcavelookup["2002-08"]
Gcavelookup["2002-x11"] = Gcavelookup["2005-08"]
Gcavelookup["2002-x12"] = Gcavelookup["2005-07"]
Gcavelookup["2002-x13"] = Gcavelookup["2005-06"]
@@ -733,7 +724,6 @@ def GetCaveLookup():
if not Gcavelookup[id]:
pass
elif Gcavelookup[id].kataster_number:
- #print(Gcavelookup[id], file=sys.stderr)
addmore[id] = Gcavelookup[id].kataster_number
elif Gcavelookup[id].unofficial_number:
addmore[id] = Gcavelookup[id].unofficial_number.lower()