From 8c5fdf5021481bb9ea99fa6309ebc67a5c57f5b5 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 7 May 2021 23:21:57 +0100 Subject: [PATCH] Entrance locations new report - url to cave --- core/forms.py | 2 ++ core/models/caves.py | 21 ++++++++++++++++----- templates/eastings.html | 9 ++++++--- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/core/forms.py b/core/forms.py index 896a655..a2727f8 100644 --- a/core/forms.py +++ b/core/forms.py @@ -81,6 +81,8 @@ class EntranceForm(ModelForm): exact_station = forms.CharField(required=False) northing = forms.CharField(required=False) easting = forms.CharField(required=False) + lat_wgs84 = forms.CharField(required=False, widget=forms.TextInput(attrs={'size': '10'}), label="Latitude (WSG84)") + long_wgs84 = forms.CharField(required=False, widget=forms.TextInput(attrs={'size': '10'}), label="Longitude (WSG84)") alt = forms.CharField(required=False, label="Altitude (m)") url = forms.CharField(required = False, label="URL [usually blank]", widget=forms.TextInput(attrs={'size': '45'})) class Meta: diff --git a/core/models/caves.py b/core/models/caves.py index fb62a26..5f68e77 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -347,11 +347,13 @@ class Entrance(TroggleModel): return self.findability != "S" or not self.has_photo or self.marking != "T" def get_absolute_url(self): - ancestor_titles='/'.join([subcave.title for subcave in self.get_ancestors()]) - if ancestor_titles: - res = '/'.join((self.get_root().cave.get_absolute_url(), ancestor_titles, self.title)) - else: - res = '/'.join((self.get_root().cave.get_absolute_url(), self.title)) + # ancestor_titles='/'.join([subcave.title for subcave in self.get_ancestors()]) + # if ancestor_titles: + # res = '/'.join((self.get_root().cave.get_absolute_url(), ancestor_titles, self.title)) + # else: + # res = '/'.join((self.get_root().cave.get_absolute_url(), self.title)) + # return res + res = '/'.join((self.get_root().cave.get_absolute_url(), self.title)) return res def slug(self): @@ -367,6 +369,15 @@ class Entrance(TroggleModel): self.save() return self.cached_primary_slug + def cavelist(self): + rs = [] + res = "" + for e in CaveAndEntrance.objects.filter(entrance=self): + if e.cave: + rs.append(e.cave) + return rs + + def get_file_path(self): return Path(settings.ENTRANCEDESCRIPTIONS, self.filename) diff --git a/templates/eastings.html b/templates/eastings.html index 92c69ba..40e72b6 100644 --- a/templates/eastings.html +++ b/templates/eastings.html @@ -6,18 +6,21 @@

Entrance locations

-This is work in progress (May 2021). +These are all the locations specified in Northing/Easting coordinates in the system. - + {% for ent in ents %} - + + + {% endfor %}
EntranceEastingNorthingtagtag exacttag other
CaveEntranceEastingNorthingtagtag exacttag otherslug
{{ent.name|safe}} + {% for c in ent.cavelist %}{{c.official_name|safe}}{% endfor %}{{ent.name|safe}} {{ent.easting|floatformat:2}} {{ent.northing|floatformat:2}} {{ent.tag_station}} {{ent.exact_station}} {{ent.other_station}}{{ent.slug}}