summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRad <radost.waszkiewicz@gmail.com>2019-02-28 12:36:49 +0000
committerRad <radost.waszkiewicz@gmail.com>2019-02-28 12:36:49 +0000
commit6b59e3a68908b2ee3b05e4734a8f72d10a349c34 (patch)
tree93e75e8f0994bbd1c2aed1c6d91f243d524e081c /core
parentce268ec306946e4f4aadd8ee358a28e79f22b9b3 (diff)
downloadtroggle-6b59e3a68908b2ee3b05e4734a8f72d10a349c34.tar.gz
troggle-6b59e3a68908b2ee3b05e4734a8f72d10a349c34.tar.bz2
troggle-6b59e3a68908b2ee3b05e4734a8f72d10a349c34.zip
rebuild descriptions database, some visuals
Diffstat (limited to 'core')
-rw-r--r--core/methods_millenial.py26
-rw-r--r--core/models_millenial.py33
-rw-r--r--core/views_caves.py23
3 files changed, 66 insertions, 16 deletions
diff --git a/core/methods_millenial.py b/core/methods_millenial.py
index 5d2483a..ce7ce11 100644
--- a/core/methods_millenial.py
+++ b/core/methods_millenial.py
@@ -1,2 +1,24 @@
-def emptyfun():
- return
+import utm
+import math
+from django.conf import settings
+
+def lat_lon_entrance(utmstring):
+ try:
+ x = float(utmstring.split()[0])
+ y = float(utmstring.split()[1])
+ #return ' '+str(x+y)+' '+str(y)
+ q = utm.to_latlon(x, y, 33, 'U')
+ return "{:.5f} {:.5f}".format(q[0],q[1])
+ except:
+ return 'Not found'
+
+def top_camp_distance(utmstring):
+ try:
+ x = float(utmstring.split()[0])
+ y = float(utmstring.split()[1])
+ tx = settings.TOPCAMPX
+ ty = settings.TOPCAMPY
+ dist = math.sqrt( (tx-x)*(tx-x) + (ty-y)*(ty-y) )
+ return "{:.1f}".format(dist)
+ except:
+ return 'Not found'
diff --git a/core/models_millenial.py b/core/models_millenial.py
index db893bc..c97be36 100644
--- a/core/models_millenial.py
+++ b/core/models_millenial.py
@@ -1,7 +1,7 @@
from django.db import models
from django.conf import settings
-from troggle.core.methods_millenial import *
+import troggle.core.methods_millenial as methods_millenial
#
# This file was created in 2019
@@ -37,15 +37,32 @@ class CaveM(models.Model): #instance of this class corresponds to one 'thing' th
survex_file = models.TextField() #gives path to top level survex file
total_length = models.FloatField() #holds total length of this cave (as given by cavern)
total_depth = models.FloatField() #holds total depth of this cave (as given by cavern)
- description = models.TextField() #holds decription of the cave
+ description = models.TextField() #holds link to description
+ date = models.TextField() #holds date of last visit
def top_camp_distance(self): #returns distance of this cave from topcamp
- return 0
+ return methods_millenial.top_camp_distance(self.entrance)
def top_camp_bearing(self): #returns bearing to this cave from topcamp in format 235.5 (float north-based azimuth)
- return 0
+ return methods_millenial.top_camp_bearing(self.entrance)
def top_camp_bearing_letter(self): #returns bearing to this cave from topcamp in format e.g. 'NE'
- return 0
- def last_visit(self): #returns Survey class instance of the most recent visit
- return 0
+ return methods_millenial.top_camp_bearing_letter(self.entrance)
+ def lat_lon_entrance(self): #lat_lon entrance location
+ return methods_millenial.lat_lon_entrance(self.entrance)
+
+
+class Cave_descriptionM(models.Model): #instance of this class corresponds to each of the .html files in descriptions
+ #each of those holds one XML field
+ slug = models.TextField()
+ explorers = models.TextField()
+ underground_description = models.TextField()
+ equipment = models.TextField()
+ references = models.TextField()
+ survey = models.TextField()
+ kataster_status = models.TextField()
+ underground_centre_line = models.TextField()
+ survex_file = models.TextField() #as given in .html file
+ notes = models.TextField()
+
+
class ExpeditionM(models.Model): #instance of this class corresponds to one expo (usually one year)
date = models.CharField(max_length=100) #date in format YYYY.MM.DD-YYYY.MM.DD
@@ -57,7 +74,7 @@ class SurveyM(models.Model): #instance of this class corresponds to one .svx fil
class Logbook_entryM(models.Model): #instance of this class corresponds to one bit of logbook (c.f. expo.survex.com/years/2015/logbook.html or simil)
date = models.CharField(max_length=100) #date as typed into logbook
- title = models.TextField() #contents of the logbook chunk
+ contents = models.TextField() #contents of the logbook chunk
class Parser_messageM(models.Model): #instance of this class contains one error or warining message produce by any of the parsers
parsername = models.CharField(max_length = 20) #name of parser
diff --git a/core/views_caves.py b/core/views_caves.py
index a785170..302003d 100644
--- a/core/views_caves.py
+++ b/core/views_caves.py
@@ -1,7 +1,7 @@
#!/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.models import CaveSlug, Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription, EntranceSlug, Entrance, Area, SurvexStation, CaveM, Cave_descriptionM
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
import troggle.core.models as models
import troggle.settings as settings
@@ -21,6 +21,17 @@ import settings
from PIL import Image, ImageDraw, ImageFont
import string, os, sys, subprocess
+def millenialcaves(request):
+ #RW messing around area
+ caves = CaveM.objects.all()
+ descr = Cave_descriptionM.objects.all()
+ return render_with_context(request,'millenialcaves.html',{'caves': caves,'descriptions' : descr})
+
+def millenialdescription(request, slug):
+ desc = Cave_descriptionM.objects.get(slug=slug)
+ return render_with_context(request,'cave_uground_description.html', {'cave': desc})
+
+
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."""
try:
@@ -54,16 +65,16 @@ def caveindex(request):
caves = Cave.objects.all()
notablecavehrefs = settings.NOTABLECAVESHREFS
notablecaves = [Cave.objects.get(kataster_number=kataster_number) for kataster_number in notablecavehrefs ]
- caves1623 = list(Cave.objects.filter(area__short_name = "1623"))
+ #caves1623 = list(Cave.objects.filter(area__short_name = "1623"))
+ caves1623 = list(Cave.objects.all())
caves1626 = list(Cave.objects.filter(area__short_name = "1626"))
caves1623.sort(caveCmp)
caves1626.sort(caveCmp)
return render_with_context(request,'caveindex.html', {'caves1623': caves1623, 'caves1626': caves1626, 'notablecaves':notablecaves, 'cavepage': True})
-def millenialcaves(request):
- #RW messing around area
- return HttpResponse("Test text", content_type="text/plain")
-
+
+
+
def cave3d(request, cave_id=''):