diff --git a/core/models.py b/core/models.py index 7b301f5..ca4556e 100644 --- a/core/models.py +++ b/core/models.py @@ -385,6 +385,20 @@ class Cave(TroggleModel): #href = models.CharField(max_length=100) + def hassurvey(self): + if not self.underground_centre_line: + return "No" + if (self.underground_centre_line.find(" -1 or self.underground_centre_line.find(" -1): + return "Yes" + return "Missing" + + def hassurveydata(self): + if not self.underground_centre_line: + return "No" + if self.survex_file: + return "Yes" + return "Missing" + def slug(self): primarySlugs = self.caveslug_set.filter(primary = True) if primarySlugs: @@ -394,6 +408,9 @@ class Cave(TroggleModel): if slugs: return slugs[0].slug + def ours(self): + return bool(re.search(r'CUCC', self.explorers)) + def reference(self): if self.kataster_number: return "%s-%s" % (self.kat_area(), self.kataster_number) @@ -431,6 +448,9 @@ class Cave(TroggleModel): def entrances(self): return CaveAndEntrance.objects.filter(cave=self) + + def singleentrance(self): + return len(CaveAndEntrance.objects.filter(cave=self)) == 1 def entrancelist(self): rs = [] @@ -534,6 +554,29 @@ class Entrance(TroggleModel): def __unicode__(self): return unicode(self.slug()) + + def find_location(self): + if self.tag_station: + s = SurvexStation.objects.lookup(self.tag_station) + return "%sE %sN %sAlt" % (s.x, s.y, s.z) + if self.exact_station: + s = SurvexStation.objects.lookup(self.exact_station) + return "%sE %sN %sAlt" % (s.x, s.y, s.z) + if self.other_station: + s = SurvexStation.objects.lookup(self.other_station) + return "%sE %sN %sAlt %s" % (s.x, s.y, s.z, self.other_description) + if self.bearings: + return self.bearings + + def has_photo(self): + if self.photo: + if (self.photo.find(" -1 or self.photo.find(" -1): + return "Yes" + else: + return "Missing" + else: + return "No" + def marking_val(self): for m in self.MARKING_CHOICES: if m[0] == self.marking: diff --git a/core/models_survex.py b/core/models_survex.py index b726d59..645d851 100644 --- a/core/models_survex.py +++ b/core/models_survex.py @@ -93,7 +93,10 @@ class SurvexLeg(models.Model): # class SurvexBlockLookUpManager(models.Manager): def lookup(self, name): - blocknames = name.split(".") + if name == "": + blocknames = [] + else: + blocknames = name.split(".") block = SurvexBlock.objects.get(parent=None, survexfile__path="all") for blockname in blocknames: block = SurvexBlock.objects.get(parent=block, name__iexact=blockname) diff --git a/core/views_caves.py b/core/views_caves.py index 2c32aa4..ae5f46f 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -1,4 +1,4 @@ -from troggle.core.models import Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription, Entrance +from troggle.core.models import Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription, Entrance, Area from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm import troggle.core.models as models import troggle.settings as settings @@ -204,3 +204,35 @@ def get_entrances(request, caveslug): def get_qms(request, caveslug): cave = Cave.objects.get(caveslug__slug = caveslug) return render_with_context(request,'options.html', {"items": [(e.entrance.slug(), e.entrance.slug()) for e in cave.entrances()]}) + +areanames = [ + #('', 'Location unclear'), + ('1a', '1a – Plateau: around Top Camp'), + ('1b', '1b – Western plateau near 182'), + ('1c', '1c – Eastern plateau near 204 walk-in path'), + ('1d', '1d – Further plateau around 76'), + ('2a', '2a – Southern Schwarzmooskogel near 201 path and the Nipple'), + ('2b', '2b – Eishöhle area'), + ('2c', '2c – Kaninchenhöhle area'), + ('2d', '2d – Steinbrückenhöhle area'), + ('3', '3 – Bräuning Alm'), + ('4', '4 – Kratzer valley'), + ('5', '5 – Schwarzmoos-Wildensee'), + ('6', '6 – Far plateau'), + ('7', '7 – Egglgrube'), + ('8a', '8a – Loser south face'), + ('8b', '8b – Loser below Dimmelwand'), + ('8c', '8c – Augst See'), + ('8d', '8d – Loser-Hochganger ridge'), + ('9', '9 – Gschwandt Alm'), + ('10', '10 – Altaussee'), + ('11', '11 – Augstbach') + ] + + +def prospecting(request): + for key, name in areanames: + print key, Area.objects.get(short_name = key) + areas = [ (name, Area.objects.get(short_name = key)) for key, name in areanames ] + return render_with_context(request,'prospecting.html', {"areas": areas}) + diff --git a/databaseReset.py b/databaseReset.py index a9e408f..7f302d5 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -73,16 +73,6 @@ def import_surveyscans(): import parsers.surveys parsers.surveys.LoadListScans() - -def import_descriptions(): - import parsers.descriptions - parsers.descriptions.getDescriptions() - -def parse_descriptions(): - import parsers.descriptions - parsers.descriptions.parseDescriptions() - parsers.descriptions.parseDescriptionsOnCaveObjects() - def import_tunnelfiles(): import parsers.surveys parsers.surveys.LoadTunnelFiles() @@ -106,17 +96,7 @@ def reset(): print "Tunnel files parser broken." import_surveys() - import_descriptions() - parse_descriptions() -def resetdesc(): - """ Wipe the troggle database and import descriptions - """ - import core.models - for desc in core.models.CaveDescription.objects.all(): - desc.delete() - import_descriptions() - parse_descriptions() def import_auto_logbooks(): import parsers.logbooks diff --git a/parsers/caves.py b/parsers/caves.py index 43d3688..1c8bf2f 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -73,6 +73,7 @@ def readentrance(filename): e.save() primary = True for slug in slugs: + print slug, filename cs = models.EntranceSlug(entrance = e, slug = slug, primary = primary) diff --git a/parsers/descriptions.py b/parsers/descriptions.py deleted file mode 100644 index cf744fe..0000000 --- a/parsers/descriptions.py +++ /dev/null @@ -1,45 +0,0 @@ -from django.conf import settings -import core.models as models -import os -from utils import html_to_wiki, get_html_body, get_html_title - -pages = [(["smkridge", "204", "ariston-rigging.html"], "ariston-rigging"), - (["smkridge", "204", "ariston.html"], "ariston"), - (["smkridge", "204", "bivvy.html"], "bivvy"), - (["smkridge", "204", "bridge.html"], "bridge"), - (["smkridge", "204", "entrance-rigging.html"], "entrance-rigging"), - (["smkridge", "204", "entrance.html"], "entrance"), - (["smkridge", "204", "midlevel.html"], "midlevel"), - (["smkridge", "204", "millennium.html"], "millennium"), - (["smkridge", "204", "nopain.html"], "nopain"), - (["smkridge", "204", "razordance.html"], "razordance"), - (["smkridge", "204", "rhino.html"], "rhino"), - (["smkridge", "204", "sbview.html"], "sbview"), - (["smkridge", "204", "subway.html"], "subway"), - (["smkridge", "204", "swings.html"], "swings"), - (["smkridge", "204", "treeumphant.html"], "treeumphant"), - (["smkridge", "204", "uworld.html"], "uworld"), ] - - -def getDescriptions(): - """Creates objects in the database for each item in the list 'pages' . """ - for filelocation, name in pages: - f = open(os.path.join(settings.EXPOWEB, *filelocation), "r") - html = f.read() - - cd = models.CaveDescription(short_name = name, - long_name = unicode(get_html_title(html), "latin1"), - description = unicode(get_html_body(html), "latin1")) - cd.save() - -def parseDescriptions(): - """Turns the HTML in each cave description into wikicode""" - for cd in models.CaveDescription.objects.all(): - cd.description = html_to_wiki(cd.description) - - cd.save() - -def parseDescriptionsOnCaveObjects(): - for cave in models.Cave.objects.all(): - cave.underground_description=html_to_wiki(unicode(cave.underground_description)) - cave.save() \ No newline at end of file diff --git a/parsers/survex.py b/parsers/survex.py index d43c303..ce81a72 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -256,7 +256,7 @@ def LoadPos(): try: ss = models.SurvexStation.objects.lookup(name) except: - print name + print "%s not parsed in survex" % name ss.x = float(x) ss.y = float(y) ss.z = float(z) diff --git a/templates/cave_uground_description.html b/templates/cave_uground_description.html index 66cc62c..86a5e7e 100644 --- a/templates/cave_uground_description.html +++ b/templates/cave_uground_description.html @@ -1,4 +1,4 @@ -

{% if cave.explorers %} +

{% if cave.explorers %}

Explorers

{{ cave.explorers|safe }} {% endif %} diff --git a/urls.py b/urls.py index 4b55143..1ff174d 100644 --- a/urls.py +++ b/urls.py @@ -64,7 +64,8 @@ actualurlpatterns = patterns('', url(r'^cave/(?P[^/]+)/(?P\d\d\d\d)-(?P\d*)(?P[ABCDX]?)?$', views_caves.qm, name="qm"), - + url(r'^prospectinguide/$', views_caves.prospecting), + url(r'^logbooksearch/(.*)/?$', views_logbooks.logbookSearch),