mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-04-02 10:21:01 +01:00
Better tag locations
This commit is contained in:
@@ -14,7 +14,7 @@ from troggle.core.models.survex import SurvexStation, utmToLatLng
|
||||
from troggle.core.models.troggle import DataIssue, TroggleModel
|
||||
from troggle.core.utils import TROG, writetrogglefile
|
||||
|
||||
# Use the TROG global object to cache the cave lookup list. No good for multi-user..
|
||||
# Use the TROG global object to cache the cave lookup list. No good for multi-user.., or even multi-page. Pointless in fact.
|
||||
Gcavelookup = TROG["caves"]["gcavelookup"]
|
||||
Gcave_count = TROG["caves"]["gcavecount"]
|
||||
|
||||
@@ -63,7 +63,7 @@ class CaveAndEntrance(models.Model):
|
||||
# moved to models/logbooks.py to avoid cyclic import problem. No I don't know why either.
|
||||
|
||||
class Cave(TroggleModel):
|
||||
# too much here perhaps,
|
||||
# (far) too much here perhaps,
|
||||
areacode = models.CharField(max_length=4, blank=True, null=True) # could use models.IntegerChoices
|
||||
subarea = models.CharField(max_length=25, blank=True, null=True) # 9, 8c etc.
|
||||
depth = models.CharField(max_length=100, blank=True, null=True)
|
||||
@@ -72,7 +72,7 @@ class Cave(TroggleModel):
|
||||
equipment = models.TextField(blank=True, null=True)
|
||||
explorers = models.TextField(blank=True, null=True)
|
||||
extent = models.CharField(max_length=100, blank=True, null=True)
|
||||
filename = models.CharField(max_length=200)
|
||||
filename = models.CharField(max_length=200) # if a cave is 'pending' this is not set. Otherwise it is.
|
||||
kataster_code = models.CharField(max_length=20, blank=True, null=True)
|
||||
kataster_number = models.CharField(max_length=10, blank=True, null=True)
|
||||
kataster_status = models.TextField(blank=True, null=True)
|
||||
@@ -87,12 +87,9 @@ class Cave(TroggleModel):
|
||||
unofficial_number = models.CharField(max_length=60, blank=True, null=True)
|
||||
url = models.CharField(max_length=300, blank=True, null=True, unique = True)
|
||||
|
||||
# class Meta:
|
||||
# unique_together = (("area", "kataster_number"), ("area", "unofficial_number"))
|
||||
|
||||
# href = models.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
# we do not enforce uniqueness at the db level as that causes confusing errors for users.
|
||||
# unique_together = (("area", "kataster_number"), ("area", "unofficial_number"))
|
||||
ordering = ("kataster_code", "unofficial_number")
|
||||
|
||||
def slug(self):
|
||||
@@ -113,10 +110,6 @@ class Cave(TroggleModel):
|
||||
else:
|
||||
return self.unofficial_number
|
||||
|
||||
# def reference(self): # tidy this up, no longer used?
|
||||
# REMOVE because of confusion with cave.references which is different
|
||||
# return f"{self.areacode}-{self.number()}"
|
||||
|
||||
def get_absolute_url(self):
|
||||
# we do not use URL_ROOT any more.
|
||||
if self.kataster_number:
|
||||
@@ -159,6 +152,13 @@ class Cave(TroggleModel):
|
||||
|
||||
def entrances(self):
|
||||
return CaveAndEntrance.objects.filter(cave=self)
|
||||
|
||||
def no_location(self):
|
||||
no_data = True
|
||||
for e in CaveAndEntrance.objects.filter(cave=self):
|
||||
if e.entrance.best_station:
|
||||
no_data = False
|
||||
return no_data
|
||||
|
||||
def singleentrance(self):
|
||||
return len(CaveAndEntrance.objects.filter(cave=self)) == 1
|
||||
@@ -215,9 +215,6 @@ class Cave(TroggleModel):
|
||||
content = t.render(c)
|
||||
return (filepath, content, "utf8")
|
||||
|
||||
def getArea(self):
|
||||
return self.areacode
|
||||
|
||||
class Entrance(TroggleModel):
|
||||
MARKING_CHOICES = (
|
||||
("P", "Paint"),
|
||||
@@ -338,6 +335,10 @@ class Entrance(TroggleModel):
|
||||
return self.exact_station
|
||||
if self.other_station:
|
||||
return self.other_station
|
||||
|
||||
def best_station_object(self):
|
||||
bs = self.best_station()
|
||||
return SurvexStation.objects.get(name=bs)
|
||||
|
||||
def has_photo(self):
|
||||
if self.photo:
|
||||
|
||||
@@ -53,7 +53,7 @@ class SurvexStationLookUpManager(models.Manager):
|
||||
class SurvexStation(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
# block = models.ForeignKey("SurvexBlock", null=True, on_delete=models.SET_NULL)
|
||||
# block not used since 2020. survex stations objects are only used for entrnce locations and all taken from the .3d file
|
||||
# block not used since 2020. survex stations objects are only used for entrance locations and all taken from the .3d file
|
||||
objects = SurvexStationLookUpManager() # overwrites SurvexStation.objects and enables lookup()
|
||||
x = models.FloatField(blank=True, null=True)
|
||||
y = models.FloatField(blank=True, null=True)
|
||||
|
||||
@@ -432,7 +432,7 @@ def edit_cave(request, path="", slug=None):
|
||||
"cave": cave,
|
||||
"message": message,
|
||||
#"caveAndEntranceFormSet": ceFormSet,
|
||||
"path": path + "/",
|
||||
"path": path + "/", # used for saving images if attached
|
||||
},
|
||||
)
|
||||
|
||||
@@ -552,7 +552,7 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
||||
"entletter": entletter,
|
||||
"entletterform": entletterform, # is unset if not being used
|
||||
"entlettereditable": entlettereditable,
|
||||
"path": path + "/",
|
||||
"path": path + "/", # used for saving images if attached
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ def prospecting_image(request, name):
|
||||
(35323.60, 81357.83, 50, "74"), # From Auer map
|
||||
]:
|
||||
(N, E, D) = list(map(float, (N, E, D)))
|
||||
maparea = Cave.objects.get(kataster_number=num).getArea().short_name
|
||||
maparea = Cave.objects.get(kataster_number=num).areacode
|
||||
lo = mungecoord(N - D, E + D, name, img)
|
||||
hi = mungecoord(N + D, E - D, name, img)
|
||||
lpos = mungecoord(N - D, E, name, img)
|
||||
|
||||
@@ -289,17 +289,17 @@ def eastings(request):
|
||||
ts = e.tag_station
|
||||
if ts:
|
||||
e.tag_ts = SurvexStation.objects.get(name=ts)
|
||||
print(f"{e} {e.tag_ts} {e.tag_ts.lat()} {e.tag_ts.long()}")
|
||||
#print(f"{e} {e.tag_ts} {e.tag_ts.lat()} {e.tag_ts.long()}")
|
||||
|
||||
es = e.exact_station
|
||||
if es:
|
||||
e.tag_es = SurvexStation.objects.get(name=es)
|
||||
print(f"{e} {e.tag_es} {e.tag_es.lat()} {e.tag_es.long()}")
|
||||
#print(f"{e} {e.tag_es} {e.tag_es.lat()} {e.tag_es.long()}")
|
||||
|
||||
os = e.other_station
|
||||
if os:
|
||||
e.tag_os = SurvexStation.objects.get(name=os)
|
||||
print(f"{e} {e.tag_os} {e.tag_os.lat()} {e.tag_os.long()}")
|
||||
#print(f"{e} {e.tag_os} {e.tag_os.lat()} {e.tag_os.long()}")
|
||||
|
||||
except:
|
||||
e.tag_ss = None
|
||||
|
||||
Reference in New Issue
Block a user