From de22b071b0749fef13ea3c53faaed1adb3191356 Mon Sep 17 00:00:00 2001 From: Sam Wenham Date: Fri, 19 Jul 2019 01:04:18 +0100 Subject: Improve README Make new style QMs from survexfiles work --- core/models_survex.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core/models_survex.py') diff --git a/core/models_survex.py b/core/models_survex.py index e78cd48..3becffb 100644 --- a/core/models_survex.py +++ b/core/models_survex.py @@ -47,6 +47,8 @@ class SurvexFile(models.Model): def SetDirectory(self): dirpath = os.path.split(self.path)[0] survexdirectorylist = SurvexDirectory.objects.filter(cave=self.cave, path=dirpath) + # if self.cave is '' or self.cave is None: + # print('No cave set for survex dir %s' % self.path) if survexdirectorylist: self.survexdirectory = survexdirectorylist[0] else: @@ -74,8 +76,11 @@ class SurvexStation(models.Model): z = models.FloatField(blank=True, null=True) def __unicode__(self): - return self.block.cave.slug() + '/' + self.block.name + '/' + self.name or 'No station name' - + if self.block.cave: + # If we haven't got a cave we can't have a slug, saves a nonetype return + return self.block.cave.slug() + '/' + self.block.name + '/' + self.name or 'No station name' + else: + return str(self.block.cave) + '/' + self.block.name + '/' + self.name or 'No station name' def path(self): r = self.name b = self.block -- cgit v1.2.3