diff options
author | Sam Wenham <sam@wenhams.co.uk> | 2020-02-22 15:38:22 +0000 |
---|---|---|
committer | Sam Wenham <sam@wenhams.co.uk> | 2020-02-22 15:38:22 +0000 |
commit | 505bc48331035b6fdc9d3ca5f9de77e5a98ba267 (patch) | |
tree | ad796c10afc7b451d5080204be67d47ec65ab5a9 /core | |
parent | de22b071b0749fef13ea3c53faaed1adb3191356 (diff) | |
download | troggle-505bc48331035b6fdc9d3ca5f9de77e5a98ba267.tar.gz troggle-505bc48331035b6fdc9d3ca5f9de77e5a98ba267.tar.bz2 troggle-505bc48331035b6fdc9d3ca5f9de77e5a98ba267.zip |
Show coordinates for entrance
Use filter to find coordinates
Diffstat (limited to 'core')
-rw-r--r-- | core/admin.py | 6 | ||||
-rw-r--r-- | core/models.py | 13 |
2 files changed, 14 insertions, 5 deletions
diff --git a/core/admin.py b/core/admin.py index 392e346..0b7cf13 100644 --- a/core/admin.py +++ b/core/admin.py @@ -28,6 +28,10 @@ class SurvexBlockAdmin(TroggleModelAdmin): inlines = (RoleInline,) +class SurvexStationAdmin(TroggleModelAdmin): + search_fields = ('name', 'block__name') + + class ScannedImageInline(admin.TabularInline): model = ScannedImage extra = 4 @@ -136,7 +140,7 @@ admin.site.register(ScannedImage) admin.site.register(SurvexDirectory) admin.site.register(SurvexFile) -admin.site.register(SurvexStation) +admin.site.register(SurvexStation, SurvexStationAdmin) admin.site.register(SurvexBlock) admin.site.register(SurvexPersonRole) admin.site.register(SurvexScansFolder) 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 |