summaryrefslogtreecommitdiffstats
path: root/core/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/models.py')
-rw-r--r--core/models.py70
1 files changed, 55 insertions, 15 deletions
diff --git a/core/models.py b/core/models.py
index e064814..a3bd832 100644
--- a/core/models.py
+++ b/core/models.py
@@ -249,7 +249,7 @@ class LogbookEntry(TroggleModel):
filename = models.CharField(max_length=200,null=True)
class Meta:
- verbose_name_plural = "Logbook Entries"
+ verbose_name_plural = "Logbook Entries"
# several PersonTrips point in to this object
ordering = ('-date',)
@@ -397,11 +397,14 @@ class Cave(TroggleModel):
#href = models.CharField(max_length=100)
+
+ class Meta:
+ ordering = ('kataster_code', 'unofficial_number')
def hassurvey(self):
if not self.underground_centre_line:
return "No"
- if (self.underground_centre_line.find("<img") > -1 or self.underground_centre_line.find("<a") > -1):
+ if (self.survey.find("<img") > -1 or self.survey.find("<a") > -1 or self.survey.find("<IMG") > -1 or self.survey.find("<A") > -1):
return "Yes"
return "Missing"
@@ -501,8 +504,17 @@ class Cave(TroggleModel):
u8 = u.encode("utf-8")
f.write(u8)
f.close()
-
-
+
+ def getArea(self):
+ areas = self.area.all()
+ lowestareas = list(areas)
+ for area in areas:
+ if area.parent in areas:
+ try:
+ lowestareas.remove(area.parent)
+ except:
+ pass
+ return lowestareas[0]
def getCaveByReference(reference):
areaname, code = reference.split("-", 1)
@@ -539,7 +551,7 @@ class Entrance(TroggleModel):
('P?', 'Paint (?)'),
('T', 'Tag'),
('T?', 'Tag (?)'),
- ('R', 'Retagged'),
+ ('R', 'Needs Retag'),
('S', 'Spit'),
('S?', 'Spit (?)'),
('U', 'Unmarked'),
@@ -548,7 +560,7 @@ class Entrance(TroggleModel):
marking_comment = models.TextField(blank=True,null=True)
FINDABLE_CHOICES = (
('?', 'To be confirmed ...'),
- ('S', 'Surveyed'),
+ ('S', 'Coordinates'),
('L', 'Lost'),
('R', 'Refindable'))
findability = models.CharField(max_length=1, choices=FINDABLE_CHOICES, blank=True, null=True)
@@ -575,21 +587,46 @@ class Entrance(TroggleModel):
def find_location(self):
+ r = {'': 'To be entered ',
+ '?': 'To be confirmed:',
+ 'S': '',
+ 'L': 'Lost:',
+ 'R': 'Refindable:'}[self.findability]
+ if self.tag_station:
+ try:
+ s = SurvexStation.objects.lookup(self.tag_station)
+ 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)
+ 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)
+ 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
+ if self.FINDABLE_CHOICES == "S":
+ r += "ERROR, Entrance has been surveyed but has no survex point"
+ if self.bearings:
+ return r + self.bearings
+ return r
+
+ def best_station(self):
if self.tag_station:
- s = SurvexStation.objects.lookup(self.tag_station)
- return "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z)
+ return self.tag_station
if self.exact_station:
- s = SurvexStation.objects.lookup(self.exact_station)
- return "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z)
+ return self.exact_station
if self.other_station:
- s = SurvexStation.objects.lookup(self.other_station)
- return "%0.0fE %0.0fN %0.0fAlt %s" % (s.x, s.y, s.z, self.other_description)
- if self.bearings:
- return self.bearings
+ return self.other_station
def has_photo(self):
if self.photo:
- if (self.photo.find("<img") > -1 or self.photo.find("<a") > -1):
+ if (self.photo.find("<img") > -1 or self.photo.find("<a") > -1 or self.photo.find("<IMG") > -1 or self.photo.find("<A") > -1):
return "Yes"
else:
return "Missing"
@@ -607,6 +644,9 @@ class Entrance(TroggleModel):
def tag(self):
return SurvexStation.objects.lookup(self.tag_station)
+
+ def needs_surface_work(self):
+ return self.findability != "S" or not self.has_photo or self.marking != "T"
def get_absolute_url(self):