From da71cca22f29fcc43d2bbb049d025d8bee2b5ed3 Mon Sep 17 00:00:00 2001 From: expo Date: Thu, 1 Aug 2013 17:00:01 +0200 Subject: [PATCH] Prospecting guide and images and few minor other things. --- .hgignore | 1 + core/admin.py | 1 + core/imageposcalc.ods | Bin 0 -> 11110 bytes core/models.py | 70 +++++++--- core/views_caves.py | 233 +++++++++++++++++++++++++++++++++- core/views_survex.py | 5 +- localsettingsubuntu.py | 16 +-- settings.py | 4 +- templates/cave_entrances.html | 4 +- templates/prospecting.html | 68 +++++++--- urls.py | 2 + 11 files changed, 354 insertions(+), 50 deletions(-) create mode 100644 core/imageposcalc.ods diff --git a/.hgignore b/.hgignore index ad091eb..cb29426 100644 --- a/.hgignore +++ b/.hgignore @@ -6,3 +6,4 @@ db* localsettings.py *~ parsing_log.txt +troggle diff --git a/core/admin.py b/core/admin.py index 0192807..0c8b605 100644 --- a/core/admin.py +++ b/core/admin.py @@ -120,6 +120,7 @@ admin.site.register(LogbookEntry, LogbookEntryAdmin) admin.site.register(QM, QMAdmin) admin.site.register(Survey, SurveyAdmin) admin.site.register(ScannedImage) +admin.site.register(SurvexStation) admin.site.register(SurvexScansFolder) admin.site.register(SurvexScanSingle) diff --git a/core/imageposcalc.ods b/core/imageposcalc.ods new file mode 100644 index 0000000000000000000000000000000000000000..0cc2135652981d47a57a5fe8393eed70fd696f38 GIT binary patch literal 11110 zcmeHtbzD?i*DxuKNJvOYhje#Hmvn~%j5I?GUD72X0@B^x=>U>~(kUSdf;3VBL%jp) z)q5ZB^L^hx-(T92}tjN;241Ac7SR4(|Gbb-~$L z*#W^G4nTl|gRPYr0Bi-aXLGeTX9WSAt(;jw4nTWzkeQ1e&>qa{?BE0hm^)hnfne3Y z(Of!_oEEwb2X}oD!Dwn)y4ac81FUSF*}y*^Ssm;x!c|pdvCv7-VIWxYa#HHBdovsy zJRB+l?CG(OIP7*CL0(Ei(>-l_-bYmnNRINA!rV4HC-IX_@YCYcTk8}I=tZ=gDJ{t8 zO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Oj_}_p{avr+KT!JR82_EhwQKycT*ht^Z!v6sn C_QK%+ literal 0 HcmV?d00001 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(" -1 or self.underground_centre_line.find(" -1): + if (self.survey.find(" -1 or self.survey.find(" -1 or self.survey.find(" -1 or self.survey.find(" -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: - s = SurvexStation.objects.lookup(self.tag_station) - return "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z) + 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: - s = SurvexStation.objects.lookup(self.exact_station) - return "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z) + 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: - 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 + 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: + return self.tag_station + if self.exact_station: + return self.exact_station + if self.other_station: + return self.other_station def has_photo(self): if self.photo: - if (self.photo.find(" -1 or self.photo.find(" -1): + if (self.photo.find(" -1 or self.photo.find(" -1 or self.photo.find(" -1 or self.photo.find(" -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): diff --git a/core/views_caves.py b/core/views_caves.py index 16dbaac..7a266b5 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -1,4 +1,7 @@ -from troggle.core.models import CaveSlug, Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription, EntranceSlug, Entrance, Area +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from troggle.core.models import CaveSlug, Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription, EntranceSlug, Entrance, Area, SurvexStation from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm import troggle.core.models as models import troggle.settings as settings @@ -8,10 +11,13 @@ from django.forms.models import modelformset_factory from django import forms from django.core.urlresolvers import reverse from utils import render_with_context # see views_logbooks for explanation on this. -from django.http import HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect from django.conf import settings import re, urlparse from django.shortcuts import get_object_or_404 +import settings + +import Image, ImageDraw, ImageFont, string, os, sys def getCave(cave_id): """Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm.""" @@ -249,19 +255,21 @@ def get_qms(request, caveslug): return render_with_context(request,'options.html', {"items": [(e.entrance.slug(), e.entrance.slug()) for e in cave.entrances()]}) areanames = [ - #('', 'Location unclear'), + ('', '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'), + ('2b or 4 (unclear)', '2b or 4 (unclear)'), ('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'), + ('1626 or 6 (borderline)', '1626 or 6 (borderline)'), ('7', '7 – Egglgrube'), ('8a', '8a – Loser south face'), ('8b', '8b – Loser below Dimmelwand'), @@ -274,8 +282,221 @@ areanames = [ def prospecting(request): + #for key, name in areanames: + # print key, Area.objects.get(short_name = key) + areas = [] 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}) + a = Area.objects.get(short_name = key) + caves = list(a.cave_set.all()) + caves.sort(caveCmp) + areas.append((name, a, caves)) + return render_with_context(request, 'prospecting.html', {"areas": areas}) + +# Parameters for big map and zoomed subarea maps: +# big map first (zoom factor ignored) + +maps = { +# id left top right bottom zoom +# G&K G&K G&K G&K factor +"all": [33810.4, 85436.5, 38192.0, 81048.2, 0.35, + "All"], +"40": [36275.6, 82392.5, 36780.3, 81800.0, 3.0, + "Eishöhle"], +"76": [35440.0, 83220.0, 36090.0, 82670.0, 1.3, + "Eislufthöhle"], +"204": [36354.1, 84154.5, 37047.4, 83300, 3.0, + "Steinbrückenhöhle"], +"tc": [35230.0, 82690.0, 36110.0, 82100.0, 3.0, + "Near Top Camp"], +"grieß": + [36000.0, 86300.0, 38320.0, 84400.0, 4.0, + "Grießkogel Area"], +} + +for n in maps.keys(): + L, T, R, B, S, name = maps[n] + W = (R-L)/2 + H = (T-B)/2 + for i in range(2): + for j in range(2): + maps["%s%i%i" % (n, i, j)] = [L + i * W, T - j * H, L + (i + 1) * W, T - (j + 1) * H, S, name] +# Keys in the order in which we want the maps output +mapcodes = ["all", "grieß","40", "76", "204", "tc"] +# Field codes +L = 0 +T = 1 +R = 2 +B = 3 +ZOOM = 4 +DESC = 5 + +areacolours = { + '1a' : '#00ffff', + '1b' : '#ff00ff', + '1c' : '#ffff00', + '1d' : '#ffffff', + '2a' : '#ff0000', + '2b' : '#00ff00', + '2c' : '#008800', + '2d' : '#ff9900', + '3' : '#880000', + '4' : '#0000ff', + '6' : '#000000', # doubles for surface fixed pts, and anything else + '7' : '#808080' + } + + +for FONT in [ + "/usr/share/fonts/truetype/freefont/FreeSans.ttf", + "/usr/X11R6/lib/X11/fonts/truetype/arial.ttf", + "C:\WINNT\Fonts\ARIAL.TTF" + ]: + if os.path.isfile(FONT): break +TEXTSIZE = 16 +CIRCLESIZE =8 +LINEWIDTH = 2 +myFont = ImageFont.truetype(FONT, TEXTSIZE) + +def mungecoord(x, y, mapcode, img): + # Top of Zinken is 73 1201 = dataset 34542 81967 + # Top of Hinter is 1073 562 = dataset 36670 83317 + # image is 1417 by 2201 + # FACTOR1 = 1000.0 / (36670.0-34542.0) + # FACTOR2 = (1201.0-562.0) / (83317 - 81967) + # FACTOR = (FACTOR1 + FACTOR2)/2 + # The factors aren't the same as the scanned map's at a slight angle. I + # can't be bothered to fix this. Since we zero on the Hinter it makes + # very little difference for caves in the areas round 76 or 204. + # xoffset = (x - 36670)*FACTOR + # yoffset = (y - 83317)*FACTOR + # return (1073 + xoffset, 562 - yoffset) + + m = maps[mapcode] + factorX, factorY = img.size[0] / (m[R] - m[L]), img.size[1] / (m[T] - m[B]) + return ((x - m[L]) * factorX, (m[T] - y) * factorY) + +COL_TYPES = {True: "red", + False: "#dddddd", + "Reference": "#dddddd"} + +def plot(surveypoint, number, point_type, label, mapcode, draw, img): + try: + ss = SurvexStation.objects.lookup(surveypoint) + E, N = ss.x, ss.y + shortnumber = number.replace("—","") + (x,y) = map(int, mungecoord(E, N, mapcode, img)) + #imgmaps[maparea].append( [x-4, y-SIZE/2, x+4+draw.textsize(shortnumber)[0], y+SIZE/2, shortnumber, label] ) + draw.rectangle([(x+CIRCLESIZE, y-TEXTSIZE/2), (x+CIRCLESIZE*2+draw.textsize(shortnumber)[0], y+TEXTSIZE/2)], fill="#ffffff") + draw.text((x+CIRCLESIZE * 1.5,y-TEXTSIZE/2), shortnumber, fill="#000000") + draw.ellipse([(x-CIRCLESIZE,y-CIRCLESIZE),(x+CIRCLESIZE,y+CIRCLESIZE)], fill=COL_TYPES[point_type], outline="#000000") + except: + pass + +def prospecting_image(request, name): + + mainImage = Image.open(os.path.join(settings.SURVEY_SCANS, "location_maps", "pguidemap.jpg")) + if settings.PUBLIC_SITE and not request.user.is_authenticated(): + mainImage = Image.new("RGB", mainImage.size, '#ffffff') + m = maps[name] + #imgmaps = [] + if name == "all": + img = mainImage + else: + M = maps['all'] + W, H = mainImage.size + l = int((m[L] - M[L]) / (M[R] - M[L]) * W) + t = int((m[T] - M[T]) / (M[B] - M[T]) * H) + r = int((m[R] - M[L]) / (M[R] - M[L]) * W) + b = int((m[B] - M[T]) / (M[B] - M[T]) * H) + img = mainImage.crop((l, t, r, b)) + w = int(round(m[ZOOM] * (m[R] - m[L]) / (M[R] - M[L]) * W)) + h = int(round(m[ZOOM] * (m[B] - m[T]) / (M[B] - M[T]) * H)) + img = img.resize((w, h), Image.BICUBIC) + draw = ImageDraw.Draw(img) + draw.setfont(myFont) + if name == "all": + for maparea in maps.keys(): + if maparea == "all": + continue + localm = maps[maparea] + l,t = mungecoord(localm[L], localm[T], "all", img) + r,b = mungecoord(localm[R], localm[B], "all", img) + text = maparea + " map" + textlen = draw.textsize(text)[0] + 3 + draw.rectangle([l, t, l+textlen, t+TEXTSIZE+2], fill='#ffffff') + draw.text((l+2, t+1), text, fill="#000000") + #imgmaps.append( [l, t, l+textlen, t+SIZE+2, "submap" + maparea, maparea + " subarea map"] ) + draw.line([l, t, r, t], fill='#777777', width=LINEWIDTH) + draw.line([l, b, r, b], fill='#777777', width=LINEWIDTH) + draw.line([l, t, l, b], fill='#777777', width=LINEWIDTH) + draw.line([r, t, r, b], fill='#777777', width=LINEWIDTH) + draw.line([l, t, l+textlen, t], fill='#777777', width=LINEWIDTH) + draw.line([l, t+TEXTSIZE+2, l+textlen, t+TEXTSIZE+2], fill='#777777', width=LINEWIDTH) + draw.line([l, t, l, t+TEXTSIZE+2], fill='#777777', width=LINEWIDTH) + draw.line([l+textlen, t, l+textlen, t+TEXTSIZE+2], fill='#777777', width=LINEWIDTH) + #imgmaps[maparea] = [] + # Draw scale bar + m100 = int(100 / (m[R] - m[L]) * img.size[0]) + draw.line([10, TEXTSIZE*3, 10, TEXTSIZE*2], fill='#000000', width=LINEWIDTH) + draw.line([10, TEXTSIZE*2, 10+m100, TEXTSIZE*2], fill='#000000', width=LINEWIDTH) + draw.line([10+m100, TEXTSIZE * 3, 10+m100, TEXTSIZE*2], fill='#000000', width=LINEWIDTH) + label = "100m" + draw.text([10 + (m100 - draw.textsize(label)[0]) / 2, TEXTSIZE/2], label, fill='#000000') + plot("laser.0_7", "BNase", "Reference", "Bräuning Nase laser point", name, draw, img) + plot("226-96", "BZkn", "Reference", "Bräuning Zinken trig point", name, draw, img) + plot("vd1","VD1","Reference", "VD1 survey point", name, draw, img) + plot("laser.kt114_96","HSK","Reference", "Hinterer Schwarzmooskogel trig point", name, draw, img) + plot("2000","Nipple","Reference", "Nipple (Weiße Warze)", name, draw, img) + plot("3000","VSK","Reference", "Vorderer Schwarzmooskogel summit", name, draw, img) + plot("topcamp", "TC", "Reference", "Top Camp", name, draw, img) + plot("laser.0", "LSR0", "Reference", "Laser Point 0", name, draw, img) + plot("laser.0_1", "LSR1", "Reference", "Laser Point 0/1", name, draw, img) + plot("laser.0_3", "LSR3", "Reference", "Laser Point 0/3", name, draw, img) + plot("laser.0_5", "LSR5", "Reference", "Laser Point 0/5", name, draw, img) + plot("225-96", "BAlm", "Reference", "Bräuning Alm trig point", name, draw, img) + for entrance in Entrance.objects.all(): + station = entrance.best_station() + if station: + #try: + areaName = entrance.caveandentrance_set.all()[0].cave.getArea().short_name + plot(station, "%s-%s" % (areaName, str(entrance)[5:]), entrance.needs_surface_work(), str(entrance), name, draw, img) + #except: + # pass + + for (N, E, D, num) in [(35975.37, 83018.21, 100,"177"), # Calculated from bearings + (35350.00, 81630.00, 50, "71"), # From Auer map + (36025.00, 82475.00, 50, "146"), # From mystery map + (35600.00, 82050.00, 50, "35"), # From Auer map + (35650.00, 82025.00, 50, "44"), # From Auer map + (36200.00, 82925.00, 50, "178"), # Calculated from bearings + (35232.64, 82910.37, 25, "181"), # Calculated from bearings + (35323.60, 81357.83, 50, "74") # From Auer map + ]: + (N,E,D) = map(float, (N, E, D)) + maparea = Cave.objects.get(kataster_number = num).getArea().short_name + lo = mungecoord(N-D, E+D, name, img) + hi = mungecoord(N+D, E-D, name, img) + lpos = mungecoord(N-D, E, name, img) + draw.ellipse([lo,hi], outline="#000000") + draw.ellipse([lo[0]+1, lo[1]+1, hi[0]-1, hi[1]-1], outline=areacolours[maparea]) + draw.ellipse([lo[0]+2, lo[1]+2, hi[0]-2, hi[1]-2], outline=areacolours[maparea]) + draw.rectangle([lpos[0],lpos[1]-TEXTSIZE/2, lpos[0] + draw.textsize(name)[0], lpos[1]+TEXTSIZE/2], fill="#ffffff") + draw.text((lpos[0], lpos[1]-TEXTSIZE/2), num, fill="#000000") + response = HttpResponse(content_type = "image/png") + del draw + img.save(response, "PNG") + return response + +STATIONS = {} +poslineregex = re.compile("^\(\s*([+-]?\d*\.\d*),\s*([+-]?\d*\.\d*),\s*([+-]?\d*\.\d*)\s*\)\s*([^\s]+)$") +def LoadPos(): + call([settings.CAVERN, "--output=%s/all.3d" % settings.SURVEX_DATA, "%s/all.svx" % settings.SURVEX_DATA]) + call([settings.THREEDTOPOS, '%sall.3d' % settings.SURVEX_DATA], cwd = settings.SURVEX_DATA) + posfile = open("%sall.pos" % settings.SURVEX_DATA) + posfile.readline()#Drop header + for line in posfile.readlines(): + r = poslineregex.match(line) + if r: + x, y, z, name = r.groups() + STATIONS[name] = (x, y, z) diff --git a/core/views_survex.py b/core/views_survex.py index cf3b556..3c53625 100644 --- a/core/views_survex.py +++ b/core/views_survex.py @@ -243,7 +243,8 @@ def identifycavedircontents(gcavedir): else: subsvx.append(nf) else: - assert re.match(".*?(?:.3d|.log|.err|.txt|.tmp|.diff|.e?spec|~)$", f), (gcavedir, f) + pass + #assert re.match(".*?(?:.3d|.log|.err|.txt|.tmp|.diff|.e?spec|~)$", f), (gcavedir, f) subsvx.sort() #assert primesvx, (gcavedir, subsvx) if primesvx: @@ -317,4 +318,4 @@ def survexcavesingle(request, survex_cave): - \ No newline at end of file + diff --git a/localsettingsubuntu.py b/localsettingsubuntu.py index 5a1f944..fcc8a73 100644 --- a/localsettingsubuntu.py +++ b/localsettingsubuntu.py @@ -2,13 +2,13 @@ import sys # link localsettings to this file for use on expo computer in austria DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': 'troggle', # Or path to database file if using sqlite3. - 'USER': 'expo', # Not used with sqlite3. - 'PASSWORD': 'gosser', # Not used with sqlite3. - 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. - 'PORT': '', # Set to empty string for default. Not used with sqlite3. + 'default': { + 'ENGINE': 'django.db.backends.mysql', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'NAME' : 'troggle', # Or path to database file if using sqlite3. + 'USER' : 'expo', # Not used with sqlite3. + 'PASSWORD' : 'gosser', # Not used with sqlite3. + 'HOST' : '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT' : '', # Set to empty string for default. Not used with sqlite3. } } @@ -30,7 +30,7 @@ SURVEY_SCANS = REPOS_ROOT_PATH + 'expoimages/' FILES = REPOS_ROOT_PATH + 'expoimages' -PYTHON_PATH = REPOS_ROOT_PATH + 'hg/troggle/' +PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/' #URL_ROOT = 'http://127.0.0.1:8000' URL_ROOT = "http://expoweb/" diff --git a/settings.py b/settings.py index 47d48ae..0032c2a 100644 --- a/settings.py +++ b/settings.py @@ -52,8 +52,8 @@ SECRET_KEY = 'a#vaeozn0)uz_9t_%v5n#tj)m+%ace6b_0(^fj!355qki*v)j2' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.load_template_source', ) diff --git a/templates/cave_entrances.html b/templates/cave_entrances.html index 3a75a02..5b70196 100644 --- a/templates/cave_entrances.html +++ b/templates/cave_entrances.html @@ -46,13 +46,13 @@
Location
{{ ent.entrance.northing|safe }}, {{ ent.entrance.easting|safe }}, {{ ent.entrance.alt|safe }}m
{% endif %} {% if ent.entrance.tag_station %} -
Tag Location
{{ ent.entrance.tag_station }}{{ ent.entrance.tag.y|safe }}, {{ ent.entrance.tag.x|safe }}, {{ ent.entrance.tag.z|safe }}m
+
Tag Location
{{ ent.entrance.tag_station }} {{ ent.entrance.tag.y|safe }}, {{ ent.entrance.tag.x|safe }}, {{ ent.entrance.tag.z|safe }}m
{% endif %} {% if ent.entrance.bearings %}
Bearings
{{ ent.entrance.bearings|safe }}
{% endif %} {% if ent.entrance.exact_station %} -
Exact Station
{{ ent.entrance.exact_station|safe }} {{ ent.exact_location.tag.y|safe }}, {{ ent.entrance.exact_location.x|safe }}, {{ ent.entrance.exact_location.z|safe }}m
+
Exact Station
{{ ent.entrance.exact_station|safe }} {{ ent.entrance.exact_location.y|safe }}, {{ ent.entrance.exact_location.x|safe }}, {{ ent.entrance.exact_location.z|safe }}m
{% endif %} {% if ent.entrance.other_station %}
Other Station
{{ ent.entrance.other_station|safe }} diff --git a/templates/prospecting.html b/templates/prospecting.html index 0d7a0d6..a2ab512 100644 --- a/templates/prospecting.html +++ b/templates/prospecting.html @@ -11,18 +11,18 @@
  • For more info on each cave, see the links to detailed description pages.
  • -{% for name, area in areas %} +{% for name, area, caves in areas %}

    {{name|safe}}

    - - +
    + - + - {% for cave in area.cave_set.all %} + {% for cave in caves %} {% if cave.singleentrance %} - + @@ -30,13 +30,32 @@ - + {% if cave.caveandentrance_set.all.0.entrance.location_description %} + + {% endif %} + {% if cave.caveandentrance_set.all.0.entrance.map_description %} + + {% endif %} + {% if cave.caveandentrance_set.all.0.entrance.approach %} + + {% endif %} + {% if cave.caveandentrance_set.all.0.entrance.findability_description %} + + {% endif %} + {% if cave.caveandentrance_set.all.0.entrance.marking_comment %} + + {% endif %} + {% if cave.caveandentrance_set.all.0.entrance.entrance_description %} + + {% endif %} + {% if cave.underground_description %} + + {% endif %} + {% else %} - + @@ -46,20 +65,39 @@ + {% if cave.underground_description %} + + {% endif %} {% for caveandentrance in cave.caveandentrance_set.all %} - + - - + + + {% if caveandentrance.entrance.location_description %} + + {% endif %} + {% if caveandentrance.entrance.map_description %} + + {% endif %} + {% if caveandentrance.entrance.approach %} + + {% endif %} + {% if caveandentrance.entrance.findability_description %} + + {% endif %} + {% if caveandentrance.entrance.marking_comment %} + + {% endif %} + {% if cave.caveandentrance_set.all.0.entrance.entrance_description %} + + {% endif %} {% endfor %} {% endif %} {% endfor %} diff --git a/urls.py b/urls.py index 106195d..fb2f698 100644 --- a/urls.py +++ b/urls.py @@ -139,6 +139,8 @@ actualurlpatterns = patterns('', (r'^photos/(?P.*)$', 'django.views.static.serve', {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}), + + url(r'^prospecting/(?P[^.]+).png$', prospecting_image, name="prospecting_image"), # (r'^gallery/(?P.*)$', 'django.views.static.serve', # {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
    Cave NumberNameFinishedSurvey
    Data
    Survey
    Drawn
    MarkedPhotoPositionLocation
    Cave NumberNameFinishedSurvey
    Data
    Survey
    Drawn
    MarkedPhotoPosition
    {{ cave }}{{ cave }} {{ cave.official_name|safe }} {{ cave.kataster_code }} {{ cave.hassurveydata }}{{ cave.caveandentrance_set.all.0.entrance.marking_val }} {{ cave.caveandentrance_set.all.0.entrance.has_photo }} {{ cave.caveandentrance_set.all.0.entrance.find_location }}{% if cave.caveandentrance_set.all.0.entrance.location_description %}Location: {{ cave.caveandentrance_set.all.0.entrance.location_description|safe }}{% endif %} - {% if cave.caveandentrance_set.all.0.entrance.map_description %}Map: {{ cave.caveandentrance_set.all.0.entrance.map_description|safe }}{% endif %} - {% if cave.caveandentrance_set.all.0.entrance.approach %}Approach: {{ cave.caveandentrance_set.all.0.entrance.approach|safe }}{% endif %}
    Location{{ cave.caveandentrance_set.all.0.entrance.location_description|safe }}
    Map{{ cave.caveandentrance_set.all.0.entrance.map_description|safe }}
    Approach{{ cave.caveandentrance_set.all.0.entrance.approach|safe }}
    Findability{{ cave.caveandentrance_set.all.0.entrance.findability_description|safe }}
    Marking{{ cave.caveandentrance_set.all.0.entrance.marking_comment|safe }}
    Ent Desc{{ cave.caveandentrance_set.all.0.entrance.entrance_description|safe }}
    Under Desc{{ cave.underground_description|truncatewords_html:80 }}
    {{ cave }}{{ cave }} {{ cave.official_name|safe }} {{ cave.kataster_code }} {{ cave.hassurveydata }}
    Under Desc{{ cave.underground_description|truncatewords_html:80 }}
    {{ caveandentrance.entrance_letter}}{{ caveandentrance.entrance_letter}} {{ caveandentrance.entrance.name|safe }} {{ caveandentrance.entrance.marking_val }} {{ caveandentrance.entrance.has_photo }} {{ caveandentrance.entrance.find_location|safe }}{% if cave.caveandentrance_set.all.0.entrance.location_description %}Location: {{ cave.caveandentrance_set.all.0.entrance.location_description|safe }}{% endif %} - {% if cave.caveandentrance_set.all.0.entrance.map_description %}Map: {{ cave.caveandentrance_set.all.0.entrance.map_description|safe }}{% endif %} - {% if cave.caveandentrance_set.all.0.entrance.approach %}Approach: {{ cave.caveandentrance_set.all.0.entrance.approach|safe }}{% endif %}{{ caveandentrance.entrance.find_location|safe }}
    Location{{ caveandentrance.entrance.location_description|safe }}
    Map{{ caveandentrance.entrance.map_description|safe }}
    Approach{{ caveandentrance.entrance.approach|safe }}
    Findability{{ caveandentrance.entrance.findability_description|safe }}
    Marking{{ caveandentrance.entrance.marking_comment|safe }}
    Ent Desc{{ caveandentrance.entrance.entrance_description|safe }}