From 505bc48331035b6fdc9d3ca5f9de77e5a98ba267 Mon Sep 17 00:00:00 2001 From: Sam Wenham Date: Sat, 22 Feb 2020 15:38:22 +0000 Subject: Show coordinates for entrance Use filter to find coordinates --- core/models.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'core/models.py') diff --git a/core/models.py b/core/models.py index 46a86da..af25107 100644 --- a/core/models.py +++ b/core/models.py @@ -372,6 +372,7 @@ class CaveAndEntrance(models.Model): cave = models.ForeignKey('Cave') entrance = models.ForeignKey('Entrance') entrance_letter = models.CharField(max_length=20,blank=True,null=True) + def __unicode__(self): return unicode(self.cave) + unicode(self.entrance_letter) @@ -605,31 +606,35 @@ class Entrance(TroggleModel): def exact_location(self): return SurvexStation.objects.lookup(self.exact_station) + def other_location(self): return SurvexStation.objects.lookup(self.other_station) def find_location(self): r = {'': 'To be entered ', - '?': 'To be confirmed:', + '?': 'To be confirmed:', 'S': '', 'L': 'Lost:', 'R': 'Refindable:'}[self.findability] if self.tag_station: try: - s = SurvexStation.objects.lookup(self.tag_station) + s = SurvexStation.objects.filter(name=self.tag_station)[:1] + s = s[0] return r + "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z) except: return r + "%s Tag Station not in dataset" % self.tag_station if self.exact_station: try: - s = SurvexStation.objects.lookup(self.exact_station) + s = SurvexStation.objects.filter(name=self.exact_station)[:1] + s = s[0] return r + "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z) except: return r + "%s Exact Station not in dataset" % self.tag_station if self.other_station: try: - s = SurvexStation.objects.lookup(self.other_station) + s = SurvexStation.objects.filter(name=self.other_station)[:1] + s = s[0] return r + "%0.0fE %0.0fN %0.0fAlt %s" % (s.x, s.y, s.z, self.other_description) except: return r + "%s Other Station not in dataset" % self.tag_station -- cgit v1.2.3