forked from expo/troggle
cleaner survexdirectory creation
This commit is contained in:
parent
d4c213e0b3
commit
73e9ae54fa
@ -12,7 +12,7 @@ from django.utils.timezone import get_current_timezone
|
||||
from django.utils.timezone import make_aware
|
||||
|
||||
import troggle.settings as settings
|
||||
from troggle.core.models.caves import Entrance, QM, LogbookEntry
|
||||
from troggle.core.models.caves import Cave, Entrance, QM, LogbookEntry
|
||||
from troggle.core.utils import get_process_memory, chaosmonkey
|
||||
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
||||
from troggle.parsers.logbooks import GetCaveLookup
|
||||
@ -1446,9 +1446,14 @@ def FindAndLoadSurvex(survexblockroot):
|
||||
def MakeSurvexFileRoot():
|
||||
"""Returns a file_object.path = SURVEX_TOPNAME associated with directory_object.path = SURVEX_DATA
|
||||
"""
|
||||
# find a cave, any cave..
|
||||
c = Cave.objects.all()
|
||||
|
||||
fileroot = SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
||||
fileroot.save()
|
||||
directoryroot = SurvexDirectory(path=settings.SURVEX_DATA, cave=None, primarysurvexfile=fileroot)
|
||||
directoryroot = SurvexDirectory(path=settings.SURVEX_DATA, cave=c[0], primarysurvexfile=fileroot)
|
||||
# MariaDB doesn't like this hack. Complains about non-null cave_id EVEN THOUGH our model file says this is OK:
|
||||
# cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL)
|
||||
directoryroot.save()
|
||||
fileroot.survexdirectory = directoryroot # i.e. SURVEX_DATA/SURVEX_TOPNAME
|
||||
fileroot.save() # mutually dependent objects need a double-save like this
|
||||
|
Loading…
Reference in New Issue
Block a user