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) diff --git a/templates/cave.html b/templates/cave.html index 870df95..c7e7a16 100644 --- a/templates/cave.html +++ b/templates/cave.html @@ -174,9 +174,7 @@ {% if ent.entrance.explorers %}
Explorers
{{ ent.entrance.explorers|safe }}
{% endif %} - {% if ent.entrance.northing %} -
Location
Easting: {{ ent.entrance.easting|safe }}, Northing: {{ ent.entrance.northing|safe }} (UTM or BMN, depending...), {{ ent.entrance.alt|safe }}m
- {% endif %} + {% if ent.entrance.lat_wgs84 %}
Location
WGS84 Lat.: {{ ent.entrance.lat_wgs84|floatformat:7 }} N, Long.:{{ ent.entrance.long_wgs84|floatformat:7 }} E
{% endif %} diff --git a/templates/entranceindex.html b/templates/entranceindex.html index 520b090..115c33b 100644 --- a/templates/entranceindex.html +++ b/templates/entranceindex.html @@ -7,14 +7,27 @@

Entrance Index

+{% for entrance in entrances %}{% if entrance.lat_wgs84 %}{{ entrance }} has "floating" lat/long {{entrance.lat_wgs84}} N, {{entrance.long_wgs84}} E instead of having a proper tag station or other station
{% endif %}{% endfor %} +

- + + + + + + {% endfor %}
NameCavesPointPosition
EntranceCavesPointTag PositionOther
{{ entrance }}{% for cave in entrance.cavelist %}{{ cave }}{% endfor %}{{ entrance.best_station }}{{ entrance.latlong }}
{{ entrance }}{% for cave in entrance.cavelist %}{{ cave }}{% endfor %} +{% if entrance.best_station%} +{{ entrance.best_station }} +{% endif %}{% if entrance.tag %} +{{ entrance.tag.latlong.0|floatformat:5}} N, {{ entrance.tag.latlong.1|floatformat:5 }} E +{% endif %}{% if entrance.other %} +{{ entrance.other.latlong.0|floatformat:5}} N, {{ entrance.other.latlong.1|floatformat:5 }} E +{% endif %}