diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-10-15 01:11:21 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-10-15 01:11:21 +0300 |
commit | c51c2326feb2a05629ca720fed31740cf73a8aa3 (patch) | |
tree | cdc4e80d9a2c729e2a2f23ad7e2f19ef71adb03f /core/models | |
parent | 5d383e0445357740b02093957aa7149975b90669 (diff) | |
download | troggle-c51c2326feb2a05629ca720fed31740cf73a8aa3.tar.gz troggle-c51c2326feb2a05629ca720fed31740cf73a8aa3.tar.bz2 troggle-c51c2326feb2a05629ca720fed31740cf73a8aa3.zip |
Better standard entrances report
Diffstat (limited to 'core/models')
-rw-r--r-- | core/models/caves.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/core/models/caves.py b/core/models/caves.py index 433ef87..a731dff 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -265,13 +265,16 @@ class Entrance(TroggleModel): return str(self.slug) def single(self, station): + if not station: + return None try: single = SurvexStation.objects.get(name = station) return single except: stations = SurvexStation.objects.filter(name = station) - print(f" # MULTIPLE stations found with same name '{station}' in Entrance {self}:") + print(f" # EXCEPTION looking for '{station}' in all stations. (Entrance {self})") if len(stations) > 1: + print(f" # MULTIPLE stations found with same name '{station}' in Entrance {self}:") for s in stations: print(f" # {s.id=} - {s.name} {s.latlong()}") # .id is Django internal field, not one of ours return stations[0] @@ -357,6 +360,8 @@ class Entrance(TroggleModel): def tag(self): return self.single(self.tag_station) + def other(self): + return self.single(self.other_station) def needs_surface_work(self): return self.findability != "S" or not self.has_photo or self.marking != "T" @@ -371,7 +376,12 @@ class Entrance(TroggleModel): if e.cave: rs.append(e.cave) return rs - + + def firstcave(self): + for e in CaveAndEntrance.objects.filter(entrance=self): + if e.cave: + return(e.cave) + def get_file_path(self): return Path(settings.ENTRANCEDESCRIPTIONS, self.filename) |