mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 10:17:47 +00: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:
|
||||
|
||||
Reference in New Issue
Block a user