From fea69c03717d700192d7a5a5afc4c27a654a923f Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 28 Jul 2022 01:48:22 +0300 Subject: Extend wallets by cave report --- core/models/survex.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'core/models/survex.py') diff --git a/core/models/survex.py b/core/models/survex.py index 1273a8b..9746afb 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -1,6 +1,8 @@ import os -from urllib.parse import urljoin import re +import json +from urllib.parse import urljoin +from pathlib import Path from django.db import models from django.conf import settings @@ -160,6 +162,9 @@ class SurvexPersonRole(models.Model): return str(self.person) + " - " + str(self.survexblock) class Wallet(models.Model): + '''We do not keep the JSON values in the database, we query them afresh each time, + but we will change this when we need to do a Django query on e.g. personame + ''' fpath = models.CharField(max_length=200) walletname = models.CharField(max_length=200) @@ -169,6 +174,31 @@ class Wallet(models.Model): def get_absolute_url(self): return urljoin(settings.URL_ROOT, reverse('singlewallet', kwargs={"path":re.sub("#", "%23", self.walletname)})) + def get_json(self): + jsonfile = Path(self.fpath, 'contents.json') + if not Path(jsonfile).is_file(): + print(f'{jsonfile} is not a file') + return None + else: + with open(jsonfile) as json_f: + try: + waldata = json.load(json_f) + except: + wurl = f"/scanupload/{self.walletname}" # .replace('#', ':') + message = f"! {str(self.walletname)} Failed to load {jsonfile} JSON file" + print(message) + raise + + return waldata + + def date(self): + jsondata = self.get_json() + return jsondata["date"] + + def name(self): + jsondata = self.get_json() + return jsondata["name"] + def __str__(self): return str(self.walletname) + " (Wallet)" @@ -189,7 +219,7 @@ class SingleScan(models.Model): class DrawingFile(models.Model): dwgpath = models.CharField(max_length=200) dwgname = models.CharField(max_length=200) - manywallets = models.ManyToManyField("Wallet") # implicitly links via folders to scans to SVX files + dwgwallets = models.ManyToManyField("Wallet") # implicitly links via folders to scans to SVX files scans = models.ManyToManyField("SingleScan") # implicitly links via scans to SVX files dwgcontains = models.ManyToManyField("DrawingFile") # case when its a frame type filesize = models.IntegerField(default=0) -- cgit v1.2.3 From 9a461c31a882b544b3707e308f6c65ad29784625 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 28 Jul 2022 02:37:44 +0300 Subject: adding people --- core/models/survex.py | 4 ++++ templates/cavewallets.html | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'core/models/survex.py') diff --git a/core/models/survex.py b/core/models/survex.py index 9746afb..29241f9 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -195,6 +195,10 @@ class Wallet(models.Model): jsondata = self.get_json() return jsondata["date"] + def people(self): + jsondata = self.get_json() + return jsondata["people"] + def name(self): jsondata = self.get_json() return jsondata["name"] diff --git a/templates/cavewallets.html b/templates/cavewallets.html index 509ca9f..49a36e3 100644 --- a/templates/cavewallets.html +++ b/templates/cavewallets.html @@ -12,13 +12,14 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c

This lists all the files in a wallet, some of which may not be for this specific cave. - + {% for wallet in manywallets|dictsort:"walletname" %} +
WalletWallet DateWallet NameScansSurvex blocksSurvex datesDrawings using these scans
WalletWallet DateWallet NamePeopleScansSurvex blocksSurvex datesDrawings using these scans
{{wallet.walletname}} {{wallet.date}} {{wallet.name}}{{wallet.people}} {{wallet.singlescan_set.all|length}} -- cgit v1.2.3 From 93622b111f4a7136033ccf844a7e03a4093cb336 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 28 Jul 2022 15:15:11 +0300 Subject: obscure bug fixed for lines ;*include --- core/models/survex.py | 2 +- parsers/survex.py | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'core/models/survex.py') diff --git a/core/models/survex.py b/core/models/survex.py index 29241f9..d8a5fb5 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -20,7 +20,7 @@ class SurvexDirectory(models.Model): verbose_name_plural = "Survex directories" def __str__(self): - return "[SurvexDirectory:"+str(self.path) + "-" + str(self.primarysurvexfile.path) + "-" + str(self.cave)+"]" + return "[SurvexDirectory:"+str(self.path) + " | Primary svx:" + str(self.primarysurvexfile.path) +".svx ]" class SurvexFile(models.Model): diff --git a/parsers/survex.py b/parsers/survex.py index 615019d..5eee625 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -130,8 +130,8 @@ class LoadingSurvex(): rx_cave = re.compile(r'(?i)caves-(\d\d\d\d)/([-\d\w]+|\d\d\d\d-?\w+-\d+)') rx_comment = re.compile(r'([^;]*?)\s*(?:;\s*(.*))?\n?$') - rx_comminc = re.compile(r'(?i)^\*include[\s]*([-\w/]*).*$') # inserted by linear collate ;*include - rx_commcni = re.compile(r'(?i)^\*edulcni[\s]*([-\w/]*).*$') # inserted by linear collate ;*edulcni + rx_comminc = re.compile(r'(?i)^\|\*include[\s]*([-\w/]*).*$') # inserted by linear collate ;*include + rx_commcni = re.compile(r'(?i)^\|\*edulcni[\s]*([-\w/]*).*$') # inserted by linear collate ;*edulcni rx_include = re.compile(r'(?i)^\s*(\*include[\s].*)$') rx_commref = re.compile(r'(?i)^\s*ref(?:erence)?[\s.:]*(\d+)\s*#\s*(X)?\s*(\d+)') rx_wallet = re.compile(r'(?i)^\s*wallet[\s.:]*(\d+)\s*#\s*(X)?\s*(\d+)') @@ -177,7 +177,7 @@ class LoadingSurvex(): callcount = 0 caverncount = 0 ignoreprefix = ["surface", "kataster", "fixedpts", "gpx"] - ignorenoncave = ["caves-1623", "caves-1623/2007-neu"] + ignorenoncave = ["caves-1623", "caves-1626", "caves-1623/2007-neu"] includedfilename ="" currentsurvexblock = None currentsurvexfile = None @@ -689,9 +689,7 @@ class LoadingSurvex(): def IdentifyCave(self, cavepath): if cavepath.lower() in self.caveslist: return self.caveslist[cavepath.lower()] - # TO DO - some of this is already done in generating self.caveslist so simplify this - # esp. as it is in a loop. - # TO DO recognise cave if different name, e.g. gruenstein == 281 + # TO DO - this predates the big revision to Gcavelookup so look at this again carefully path_match = self.rx_cave.search(cavepath) if path_match: sluggy = '{}-{}'.format(path_match.group(1), path_match.group(2)) @@ -724,17 +722,17 @@ class LoadingSurvex(): """Ignore surface, kataser and gpx *include survex files """ if headpath in self.ignorenoncave: - #message = f" - {headpath} is (while creating '{includelabel}' sfile & sdirectory)" + message = f" - {headpath} is (while creating '{includelabel}' sfile & sdirectory)" #print("\n"+message) #print("\n"+message,file=sys.stderr) return for i in self.ignoreprefix: if headpath.startswith(i): message = f" - {headpath} starts with (while creating '{includelabel}' sfile & sdirectory)" - #print("\n"+message) - #print("\n"+message,file=sys.stderr) + # print("\n"+message) + # print("\n"+message,file=sys.stderr) return - message = f" ! Error: FAILURE '{headpath}' while creating '{includelabel}' at depth:[{depth}]. Not a cave or in the ignore list:'{self.ignoreprefix}'" + message = f" ! Error: not a cave nor ignorable. headpath:'{headpath}' while creating '{includelabel=}' at depth:[{len(depth)}]. ignore prefix list:'{self.ignoreprefix}'" # getting this triggered for gpx/2018 (cavern error) but not for gpx/2017 (no content). print("\n"+message) print("\n"+message,file=sys.stderr) @@ -779,7 +777,7 @@ class LoadingSurvex(): if cave: newdirectory.cave = cave newfile.cave = cave - # print(f"\n - New directory {newdirectory} for cave {newdirectory.cave}",file=sys.stderr) + # print(f"\n - New directory '{newdirectory}' for cave '{cave}'",file=sys.stderr) else: # probably a surface survey, or a cave in a new area e.g. 1624 not previously managed, and not in the pending list self.ReportNonCaveIncludes(headpath, svxid, depth) @@ -861,6 +859,7 @@ class LoadingSurvex(): included = self.rx_comminc.match(comment) # ;*include means 'we have been included'; whereas *include means 'proceed to include' + # bug, If the original survex file contians the line ;*include then we pick it up ! So fix our special code to be ;|*include if included: self.ProcessIncludeLine(included) @@ -1210,7 +1209,7 @@ class LoadingSurvex(): #-------------------------------------------------------- self.depthinclude += 1 fininclude = open(fullpath,'r') - fcollate.write(";*include {}\n".format(includepath)) + fcollate.write(";|*include {}\n".format(includepath)) flinear.write("{:2} {} *include {}\n".format(self.depthinclude, indent, includepath)) push = includepath.lower() self.includestack.append(push) @@ -1225,7 +1224,7 @@ class LoadingSurvex(): print(message,file=sys.stderr) DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(path)) flinear.write("{:2} {} *edulcni {}\n".format(self.depthinclude, indent, pop)) - fcollate.write(";*edulcni {}\n".format(pop)) + fcollate.write(";|*edulcni {}\n".format(pop)) fininclude.close() self.depthinclude -= 1 #-------------------------------------------------------- -- cgit v1.2.3 From 724234949f1770645b0f8c34221ae16b0615daf3 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 29 Jul 2022 20:55:19 +0300 Subject: Populate blank wallet fields with survex data --- core/models/survex.py | 7 +++++- core/views/scans.py | 63 +++++++++++++++++++++++++++++++++++++++++++--- templates/cavewallets.html | 9 +++---- 3 files changed, 69 insertions(+), 10 deletions(-) (limited to 'core/models/survex.py') diff --git a/core/models/survex.py b/core/models/survex.py index d8a5fb5..79a645e 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -191,6 +191,7 @@ class Wallet(models.Model): return waldata + # Yes this is horribly, horribly inefficient, esp. for a page that have date, people and cave in it def date(self): jsondata = self.get_json() return jsondata["date"] @@ -199,12 +200,16 @@ class Wallet(models.Model): jsondata = self.get_json() return jsondata["people"] + def cave(self): + jsondata = self.get_json() + return jsondata["cave"] + def name(self): jsondata = self.get_json() return jsondata["name"] def __str__(self): - return str(self.walletname) + " (Wallet)" + return "[" + str(self.walletname) + " (Wallet)]" class SingleScan(models.Model): ffile = models.CharField(max_length=200) diff --git a/core/views/scans.py b/core/views/scans.py index 7d933c7..fda3d6d 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -1,5 +1,6 @@ import os, stat import re +import datetime from pathlib import Path from urllib.parse import urljoin, unquote as urlunquote from urllib.request import urlopen @@ -8,7 +9,7 @@ from django.conf import settings from django.shortcuts import render from django.http import HttpResponse -from troggle.core.models.survex import Wallet, SingleScan +from troggle.core.models.survex import Wallet, SingleScan, SurvexBlock from troggle.core.models.caves import GetCaveLookup from troggle.core.views.expo import getmimetype #import parsers.surveys @@ -21,9 +22,43 @@ need to check if inavlid query string is invalid, or produces multiple replies and render a user-friendly error page. ''' +def populatewallet(w): + '''Copy survex data here just for display, not permanently + ''' + # {% for personrole in wallet.survexblock.survexpersonrole_set.all %} + # {% if personrole.personexpedition %} + # {{personrole.personname}} + # {% else %} + # {{personrole.personname}} + # {% endif %} + # {% endfor %} + + survexpeople = [] + blocks = SurvexBlock.objects.filter(scanswallet = w) + for b in blocks: + for personrole in b.survexpersonrole_set.all(): + survexpeople.append(personrole.personname) + w.people = list(set(survexpeople)) # remove duplicates + +def datewallet(w, earliest): + blocks = SurvexBlock.objects.filter(scanswallet = w) + for b in blocks: + if b.date < earliest: + earliest = b.date + w.date = earliest + +def caveifywallet(w): + print('*') + blocks = SurvexBlock.objects.filter(scanswallet = w) + for b in blocks: + # NB b.cave is not populated by parser. Use b.survexfile.cave instead, or we could parse b.survexpath + if b.survexfile.cave: + w.cave = b.survexfile.cave # just gets the last one, randomly + print(w.cave) + def walletslistyear(request, year): - '''Page which displays a list of all the wallets in a specific year + '''Page which displays a list of all the wallets in a specific year - TO BE WRITTEN ''' if year < 1976 or year > 2050: return render(request, 'errors/generic.html', {'message': 'Year out of range. Must be between 1976 and 2050'}) @@ -35,16 +70,38 @@ def walletslistyear(request, year): def cavewallets(request, caveid): '''Returns all the wallets for just one cave ''' + Gcavelookup = GetCaveLookup() if caveid in Gcavelookup: cave = Gcavelookup[caveid] else: return render(request,'errors/badslug.html', {'badslug': caveid}) + earliest = datetime.datetime.now().date() + # remove duplication. SOrting is done in the template wallets = set(Wallet.objects.filter(survexblock__survexfile__cave=cave)) # NB a filtered set manywallets = list(wallets) - + + + for w in manywallets: + wp = w.people() + if not wp: # an -empty list + populatewallet(w) + else: + if len(wp) == 1: + nobody = wp[0].lower() + if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ': + populatewallet(w) + + if not w.date(): + datewallet(w, earliest) + + c = w.cave() + + if not c: + caveifywallet(w) + return render(request, 'cavewallets.html', { 'manywallets':manywallets, 'settings': settings, 'cave': cave}) def oldwallet(request, path): diff --git a/templates/cavewallets.html b/templates/cavewallets.html index 49a36e3..51e5d76 100644 --- a/templates/cavewallets.html +++ b/templates/cavewallets.html @@ -12,7 +12,7 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c

This lists all the files in a wallet, some of which may not be for this specific cave. - + {% for wallet in manywallets|dictsort:"walletname" %} @@ -20,6 +20,7 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c + - +
WalletWallet DateWallet NamePeopleScansSurvex blocksSurvex datesDrawings using these scans
WalletWallet DateWallet NamePeopleCaveScansSurvex blocksDrawings using these scans
{{wallet.walletname}}{{wallet.date}} {{wallet.name}} {{wallet.people}}{{wallet.cave}} {{wallet.singlescan_set.all|length}} @@ -27,11 +28,7 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c {{survexblock}} {% endfor %} - {% for survexblock in wallet.survexblock_set.all %} - {{survexblock.date}}   - {% endfor %} - {% for drawing in wallet.drawingfile_set.all %} {{drawing.dwgpath}}
-- cgit v1.2.3 From c1ba6a39a5f556d832da22e1f8e8ab33494f755b Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 31 Jul 2022 01:02:02 +0300 Subject: Wallets by year and by cave --- core/models/survex.py | 10 ++++++++++ core/views/scans.py | 45 ++++++++++++++++++++++++++++++++++++++------ templates/base.html | 8 ++++---- templates/cavewallets.html | 9 ++++++--- templates/manywallets.html | 5 +++++ templates/svxcavesingle.html | 1 + templates/yearwallets.html | 45 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 templates/yearwallets.html (limited to 'core/models/survex.py') diff --git a/core/models/survex.py b/core/models/survex.py index 79a645e..a84a37e 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -190,6 +190,16 @@ class Wallet(models.Model): raise return waldata + + def year(self): + if self.walletname[4] != "#": + return None + year = int(self.walletname[0:4]) + if year < 1976 or year > 2050: + return None + else: + return str(year) + # Yes this is horribly, horribly inefficient, esp. for a page that have date, people and cave in it def date(self): diff --git a/core/views/scans.py b/core/views/scans.py index fda3d6d..6ecae2b 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -20,6 +20,9 @@ by looking inside the file before being served. need to check if inavlid query string is invalid, or produces multiple replies and render a user-friendly error page. + +Note that datewallet(), caveifywallet() etc do NOT save the object to the db. They are ephemeral, just for the page rendering of the +manywallets dict. ''' def populatewallet(w): @@ -42,13 +45,13 @@ def populatewallet(w): def datewallet(w, earliest): blocks = SurvexBlock.objects.filter(scanswallet = w) - for b in blocks: - if b.date < earliest: - earliest = b.date + for b in blocks: + if b.date: + if b.date < earliest: + earliest = b.date w.date = earliest def caveifywallet(w): - print('*') blocks = SurvexBlock.objects.filter(scanswallet = w) for b in blocks: # NB b.cave is not populated by parser. Use b.survexfile.cave instead, or we could parse b.survexpath @@ -64,7 +67,38 @@ def walletslistyear(request, year): return render(request, 'errors/generic.html', {'message': 'Year out of range. Must be between 1976 and 2050'}) else: year = str(year) - return render(request, 'errors/generic.html', {'message': 'This page logic not implemented yet'}) + #return render(request, 'errors/generic.html', {'message': 'This page logic not implemented yet'}) + earliest = datetime.datetime.now().date() + + manywallets = [] + wallets = Wallet.objects.all() + for w in wallets: + + if year == w.year(): + print(w.year(), w) + manywallets.append(w) + else: + print("NOT WANTED",year, w.year()) + continue + + wp = w.people() + if not wp: # an -empty list + populatewallet(w) + else: + if len(wp) == 1: + nobody = wp[0].lower() + if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ': + populatewallet(w) + + if not w.date(): + datewallet(w, earliest) + + c = w.cave() + if not c: + caveifywallet(w) + + return render(request, 'yearwallets.html', { 'manywallets':manywallets, 'settings': settings, 'year': year}) + def cavewallets(request, caveid): @@ -98,7 +132,6 @@ def cavewallets(request, caveid): datewallet(w, earliest) c = w.cave() - if not c: caveifywallet(w) diff --git a/templates/base.html b/templates/base.html index 8f3f562..6d43e63 100644 --- a/templates/base.html +++ b/templates/base.html @@ -36,8 +36,8 @@ Drawings | Upload Drawings | Upload Photos | - 290 (FGH) | - 359 (Homecoming) | + 290 (FGH) | + 359 (Homecoming) |
Data Issues | @@ -48,8 +48,8 @@ expoers | survey lengths | statistics | - Expo2018 | - Expo2019 | + Wallets(2019) | + Expo(2019) | import/export | Django admin diff --git a/templates/cavewallets.html b/templates/cavewallets.html index 51e5d76..3208927 100644 --- a/templates/cavewallets.html +++ b/templates/cavewallets.html @@ -10,9 +10,13 @@ plans and elevations. It also contains scans of centre-line survex output on whi hand-drawn passage sections are drawn. These hand-drawn passages will eventually be traced to produce Tunnel or Therion drawings and eventually the final complete cave survey.

This lists all the files in a wallet, some of which may not be for this specific cave. +

See also wallets +

    +
  • per year, e.g. 2019 +
- + {% for wallet in manywallets|dictsort:"walletname" %} @@ -20,9 +24,8 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c - - +
WalletWallet DateWallet NamePeopleCaveScansSurvex blocksDrawings using these scans
WalletWallet DateWallet NamePeopleScansSurvex blocksDrawings using these scans
{{wallet.walletname}}{{wallet.date}} {{wallet.name}} {{wallet.people}}{{wallet.cave}}{{wallet.singlescan_set.all|length}}{{wallet.singlescan_set.all|length}} {% for survexblock in wallet.survexblock_set.all %} {{survexblock}} diff --git a/templates/manywallets.html b/templates/manywallets.html index 7fc04cb..44d097f 100644 --- a/templates/manywallets.html +++ b/templates/manywallets.html @@ -9,6 +9,11 @@ plans and elevations. It also contains scans of centre-line survex output on which hand-drawn passage sections are drawn. These hand-drawn passages will eventually be traced to produce Tunnel or Therion drawings and eventually the final complete cave survey. +

See also wallets +

Cave description: {{cave.url}} +

Wallets: {{cave|safe}}

{% for survexdirectory in cave.survexdirectory_set.all %} diff --git a/templates/yearwallets.html b/templates/yearwallets.html new file mode 100644 index 0000000..87843d2 --- /dev/null +++ b/templates/yearwallets.html @@ -0,0 +1,45 @@ +{% extends "base.html" %} + +{% block title %}One Year Survey scans folders (wallets){% endblock %} + +{% block content %} +

Wallets for {{year}}

+

Each wallet contains the scanned original in-cave survey notes and sketches of +plans and elevations. It also contains scans of centre-line survex output on which +hand-drawn passage sections are drawn. These hand-drawn passages will eventually be +traced to produce Tunnel or Therion drawings and eventually the final complete cave survey. +

This lists all the files in a wallet, some of which may not be for this specific cave. +

See also wallets +

+ + +{% for wallet in manywallets|dictsort:"walletname" %} + + + + + + + + + + + + + +{% endfor %} +
WalletWallet DateWallet NamePeopleCaveScansSurvex blocksDrawings using these scans
{{wallet.walletname}}{{wallet.date}}{{wallet.name}}{{wallet.people}}{{wallet.cave}}{{wallet.singlescan_set.all|length}} + {% for survexblock in wallet.survexblock_set.all %} + {{survexblock}} + {% endfor %} + + {% for drawing in wallet.drawingfile_set.all %} + {{drawing.dwgpath}}
+ {% empty %} + (no Tunnel drawings found: but there might be Therion drawings) + {% endfor %} +
+ +{% endblock %} \ No newline at end of file -- cgit v1.2.3 From a2a5e9200ec5a588729a19684bba9c045dad8ef6 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 31 Jul 2022 18:58:46 +0300 Subject: wallets per person - slow implementation --- core/models/survex.py | 8 +++++ core/models/troggle.py | 4 +-- core/views/scans.py | 69 +++++++++++++++++++++++++++++++++++++++----- templates/cavewallets.html | 5 ++-- templates/dataissues.html | 2 +- templates/manywallets.html | 1 + templates/personwallets.html | 46 +++++++++++++++++++++++++++++ templates/yearwallets.html | 9 +++--- urls.py | 3 +- 9 files changed, 130 insertions(+), 17 deletions(-) create mode 100644 templates/personwallets.html (limited to 'core/models/survex.py') diff --git a/core/models/survex.py b/core/models/survex.py index a84a37e..a562a44 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -203,18 +203,26 @@ class Wallet(models.Model): # Yes this is horribly, horribly inefficient, esp. for a page that have date, people and cave in it def date(self): + if not self.get_json(): + return None jsondata = self.get_json() return jsondata["date"] def people(self): + if not self.get_json(): + return None jsondata = self.get_json() return jsondata["people"] def cave(self): + if not self.get_json(): + return None jsondata = self.get_json() return jsondata["cave"] def name(self): + if not self.get_json(): + return None jsondata = self.get_json() return jsondata["name"] diff --git a/core/models/troggle.py b/core/models/troggle.py index 593bd1d..84f1bc3 100644 --- a/core/models/troggle.py +++ b/core/models/troggle.py @@ -124,11 +124,11 @@ class Person(TroggleModel): fullname = models.CharField(max_length=200) is_vfho = models.BooleanField(help_text="VFHO is the Vereines für Höhlenkunde in Obersteier, a nearby Austrian caving club.", default=False) mug_shot = models.CharField(max_length=100, blank=True,null=True) - blurb = models.TextField(blank=True,null=True) + blurb = models.TextField(blank=True,null=True) #href = models.CharField(max_length=200) orderref = models.CharField(max_length=200) # for alphabetic - user = models.OneToOneField(User, null=True, blank=True,on_delete=models.CASCADE) + user = models.OneToOneField(User, null=True, blank=True,on_delete=models.CASCADE) # not used now def get_absolute_url(self): return urljoin(settings.URL_ROOT,reverse('person',kwargs={'first_name':self.first_name,'last_name':self.last_name})) diff --git a/core/views/scans.py b/core/views/scans.py index 6ecae2b..d7c48e2 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -10,8 +10,11 @@ from django.shortcuts import render from django.http import HttpResponse from troggle.core.models.survex import Wallet, SingleScan, SurvexBlock +from troggle.core.models.troggle import Person from troggle.core.models.caves import GetCaveLookup from troggle.core.views.expo import getmimetype +#from troggle.parsers.people import GetPersonExpeditionNameLookup + #import parsers.surveys '''one of these views serves files as binary blobs, and simply set the mime type based on the file extension, @@ -41,15 +44,20 @@ def populatewallet(w): for b in blocks: for personrole in b.survexpersonrole_set.all(): survexpeople.append(personrole.personname) - w.people = list(set(survexpeople)) # remove duplicates + w.persons = list(set(survexpeople)) def datewallet(w, earliest): + first = earliest blocks = SurvexBlock.objects.filter(scanswallet = w) for b in blocks: if b.date: - if b.date < earliest: - earliest = b.date - w.date = earliest + if b.date < first: + first = b.date + if first == earliest: + # no date found + w.date = None + else: + w.date = first def caveifywallet(w): blocks = SurvexBlock.objects.filter(scanswallet = w) @@ -57,11 +65,59 @@ def caveifywallet(w): # NB b.cave is not populated by parser. Use b.survexfile.cave instead, or we could parse b.survexpath if b.survexfile.cave: w.cave = b.survexfile.cave # just gets the last one, randomly - print(w.cave) +def walletslistperson(request, first_name, last_name): + '''Page which displays a list of all the wallets for a specific person + HORRIBLE linear search through everything. Index and do SQL query properly + ''' + # This is where we face having to re-do everything to do with names properly, rather than the horrible series of hacks over 20 years.. + #GetPersonExpeditionNameLookup + + try: + if last_name: + p = Person.objects.get(fullname= f'{first_name} {last_name}') + else: + # speciall Wookey-hack + p = Person.objects.get(first_name= f'{first_name}') + except: + #raise + return render(request, 'errors/generic.html', {'message': f'Unrecognised name of a expo person: "{first_name} {last_name}"'}) + + #personyear = GetPersonExpeditionNameLookup(expedition).get(tripperson.lower()) + earliest = datetime.datetime.now().date() + + manywallets = [] + wallets = Wallet.objects.all() + for w in wallets: + w.persons = w.people() # ephemeral attribute for web page + # check if there is a json + if not w.get_json(): + populatewallet(w) + else: + wp = w.people() + if not wp: # an -empty list + populatewallet(w) + else: + if len(wp) == 1: + nobody = wp[0].lower() + if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ': + populatewallet(w) + + if p.fullname in w.persons: + #found person + manywallets.append(w) + + if not w.date(): + datewallet(w, earliest) + + c = w.cave() + if not c: + caveifywallet(w) + + return render(request, 'personwallets.html', { 'manywallets':manywallets, 'settings': settings, 'person': p}) def walletslistyear(request, year): - '''Page which displays a list of all the wallets in a specific year - TO BE WRITTEN + '''Page which displays a list of all the wallets in a specific year ''' if year < 1976 or year > 2050: return render(request, 'errors/generic.html', {'message': 'Year out of range. Must be between 1976 and 2050'}) @@ -78,7 +134,6 @@ def walletslistyear(request, year): print(w.year(), w) manywallets.append(w) else: - print("NOT WANTED",year, w.year()) continue wp = w.people() diff --git a/templates/cavewallets.html b/templates/cavewallets.html index 3208927..8fd5d83 100644 --- a/templates/cavewallets.html +++ b/templates/cavewallets.html @@ -13,17 +13,18 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c

See also wallets

- + {% for wallet in manywallets|dictsort:"walletname" %} - + + + + + + + + + + + + + + +{% for wallet in manywallets|dictsort:"walletname" %} + + + + + + + + + + + + + + + + + + +{% endfor %} +
WalletWallet DateWallet NamePeopleScansSurvex blocksDrawings using these scans
WalletWallet DateWallet NamePeopleScansSurvex blocksDrawings using these scans
{{wallet.walletname}} {{wallet.date}} {{wallet.name}}{{wallet.people}}{{wallet.persons}} {{wallet.singlescan_set.all|length}} diff --git a/templates/dataissues.html b/templates/dataissues.html index 2127a0e..97c415e 100644 --- a/templates/dataissues.html +++ b/templates/dataissues.html @@ -6,7 +6,7 @@

Loading data from files: Issues arising that need attention

-This is work in progress (June 2022).The URL links to the offending objects are enabled on only some types of fault as yet. +This is work in progress.The URL links to the offending objects are enabled on only some types of fault as yet.

See the Data Management To Do list as well as these import/parsing issues. diff --git a/templates/manywallets.html b/templates/manywallets.html index 44d097f..7295ac5 100644 --- a/templates/manywallets.html +++ b/templates/manywallets.html @@ -13,6 +13,7 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c

+
SCQNPETW
{{wallet.walletname}}{{wallet.date}}{{wallet.cave}}{{wallet.name}}        
+
{% for wallet in manywallets|dictsort:"walletname" %} @@ -43,4 +85,5 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c {% endfor %}
WalletWallet DateWallet NameOther PeopleCaveScansSurvex blocksDrawings using these scans
+ {% endblock %} \ No newline at end of file diff --git a/templates/walletform.html b/templates/walletform.html index 0bde7be..37b1c11 100644 --- a/templates/walletform.html +++ b/templates/walletform.html @@ -156,10 +156,10 @@
- +
- +
-- cgit v1.2.3 From df42b1ccb3766beb5eaadb742bf905a593143c75 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 1 Aug 2022 03:10:07 +0300 Subject: remove debugging print --- core/models/survex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/models/survex.py') diff --git a/core/models/survex.py b/core/models/survex.py index 11ef4f4..05588f9 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -296,7 +296,7 @@ class Wallet(models.Model): else: files = self.get_fnames() - print(self.walletname,files) + # Notes required notes_scanned = reduce(operator.or_, [f.startswith("note") for f in files], False) notes_scanned = reduce(operator.or_, [f.endswith("notes") for f in files], notes_scanned) -- cgit v1.2.3