diff options
Diffstat (limited to 'core/models_survex.py')
-rw-r--r-- | core/models_survex.py | 9 |
1 files changed, 7 insertions, 2 deletions
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 |