diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2020-06-16 19:27:32 +0100 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2020-06-16 19:27:32 +0100 |
commit | 94e5a06a15207c3b0b3ca7af569a72e03c7cea51 (patch) | |
tree | 7725319deac5128fd781df16e6aa8f19361abd4e /core | |
parent | 8fc0ba136fe2aba853474b0ea09a6736455c28fd (diff) | |
download | troggle-94e5a06a15207c3b0b3ca7af569a72e03c7cea51.tar.gz troggle-94e5a06a15207c3b0b3ca7af569a72e03c7cea51.tar.bz2 troggle-94e5a06a15207c3b0b3ca7af569a72e03c7cea51.zip |
clean up survexlegs
Diffstat (limited to 'core')
-rw-r--r-- | core/models_survex.py | 29 | ||||
-rw-r--r-- | core/views_other.py | 2 | ||||
-rw-r--r-- | core/views_statistics.py | 29 |
3 files changed, 36 insertions, 24 deletions
diff --git a/core/models_survex.py b/core/models_survex.py index 6499d78..f33e7b0 100644 --- a/core/models_survex.py +++ b/core/models_survex.py @@ -81,14 +81,18 @@ class SurvexStation(models.Model): else: return r -class SurvexLeg(models.Model): - block = models.ForeignKey('SurvexBlock') - #title = models.ForeignKey('SurvexTitle') - stationfrom = models.ForeignKey('SurvexStation', related_name='stationfrom') - stationto = models.ForeignKey('SurvexStation', related_name='stationto') - tape = models.FloatField() - compass = models.FloatField() - clino = models.FloatField() +# class SurvexLeg(models.Model): + # block = models.ForeignKey('SurvexBlock') + # #title = models.ForeignKey('SurvexTitle') + # stationfrom = models.ForeignKey('SurvexStation', related_name='stationfrom') + # stationto = models.ForeignKey('SurvexStation', related_name='stationto') + # tape = models.FloatField() + # compass = models.FloatField() + # clino = models.FloatField() +class SurvexLeg(): + tape = 0.0 + compass = 0.0 + clino = 0.0 # # Single SurvexBlock @@ -108,7 +112,7 @@ class SurvexBlock(models.Model): objects = SurvexBlockLookUpManager() name = models.CharField(max_length=100) parent = models.ForeignKey('SurvexBlock', blank=True, null=True) - text = models.TextField() +# text = models.TextField() cave = models.ForeignKey('Cave', blank=True, null=True) date = models.DateField(blank=True, null=True) @@ -116,13 +120,16 @@ class SurvexBlock(models.Model): expedition = models.ForeignKey('Expedition', blank=True, null=True) survexfile = models.ForeignKey("SurvexFile", blank=True, null=True) - begin_char = models.IntegerField() # code for where in the survex data files this block sits +# begin_char = models.IntegerField() # code for where in the survex data files this block sits survexpath = models.CharField(max_length=200) # the path for the survex stations survexscansfolder = models.ForeignKey("SurvexScansFolder", null=True) #refscandir = models.CharField(max_length=100) - totalleglength = models.FloatField() + legsall = models.IntegerField(null=True) # summary data for this block + legssplay = models.IntegerField(null=True) # summary data for this block + legssurfc = models.IntegerField(null=True) # summary data for this block + totalleglength = models.FloatField(null=True) class Meta: ordering = ('id',) diff --git a/core/views_other.py b/core/views_other.py index ae88305..38df56d 100644 --- a/core/views_other.py +++ b/core/views_other.py @@ -11,7 +11,7 @@ from django.template import Context, loader import troggle.parsers.imports from troggle.core.models import Expedition, Person, PersonExpedition from troggle.core.models_caves import LogbookEntry, QM, Cave, PersonTrip -from troggle.core.models_survex import SurvexLeg +#from troggle.core.models_survex import SurvexLeg from troggle.helper import login_required_if_public from troggle.core.forms import UploadFileForm diff --git a/core/views_statistics.py b/core/views_statistics.py index 86ee064..bd71a1f 100644 --- a/core/views_statistics.py +++ b/core/views_statistics.py @@ -82,19 +82,24 @@ def stats(request): statsDict['caveCount'] = "{:,}".format(Cave.objects.count()) statsDict['personCount'] = "{:,}".format(Person.objects.count()) statsDict['logbookEntryCount'] = "{:,}".format(LogbookEntry.objects.count()) - - blockroots = SurvexBlock.objects.filter(name="rootblock") - if len(blockroots)>1: - print(" ! more than one root survexblock {}".format(len(blockroots))) - for sbr in blockroots: - print("{} {} {} {}".format(sbr.id, sbr.name, sbr.text, sbr.date)) - sbr = blockroots[0] - totalsurvexlength = sbr.totalleglength try: - nimportlegs = int(sbr.text) + blockroots = SurvexBlock.objects.filter(name="rootblock") + if len(blockroots)>1: + print(" ! more than one root survexblock {}".format(len(blockroots))) + for sbr in blockroots: + print("{} {} {} {}".format(sbr.id, sbr.name, sbr.legsall, sbr.date)) + sbr = blockroots[0] + totalsurvexlength = sbr.totalleglength + nimportlegs = sbr.legsall except: - print("{} {} {} {}".format(sbr.id, sbr.name, sbr.text, sbr.date)) + # if no files yet imported into database + #survexfile = models_survex.SurvexFile(path=settings.SURVEX_TOPNAME, cave=None) + #survexblockdummy = models_survex.SurvexBlock(name="dummy", survexpath="", cave=None, survexfile=survexfile, + #legsall=0, legssplay=0, legssurfc=0, totalleglength=0.0) + #sbr = survexblockdummy + totalsurvexlength = 0.0 nimportlegs = -1 + print("{} {} {} {}".format(sbr.id, sbr.name, sbr.legsall, sbr.date)) legsbyexpo = [ ] addupsurvexlength = 0 @@ -105,14 +110,14 @@ def stats(request): for survexblock in survexblocks: survexleglength += survexblock.totalleglength try: - legsyear += int(survexblock.text) + legsyear += int(survexblock.legsall) except: pass addupsurvexlength += survexleglength legsbyexpo.append((expedition, {"nsurvexlegs": "{:,}".format(legsyear), "survexleglength":"{:,.0f}".format(survexleglength)})) legsbyexpo.reverse() - survexlegs = SurvexLeg.objects.all() + #survexlegs = SurvexLeg.objects.all() renderDict = {**statsDict, **{ "nsurvexlegs": "{:,}".format(nimportlegs), "totalsurvexlength":totalsurvexlength/1000, "addupsurvexlength":addupsurvexlength/1000, "legsbyexpo":legsbyexpo }} # new syntax return render(request,'statistics.html', renderDict) |