mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 05:37:14 +00:00
List the logbook trips and other svx files of the same date
This commit is contained in:
@@ -4,6 +4,7 @@ import json
|
||||
import settings
|
||||
import urllib
|
||||
import operator
|
||||
import datetime
|
||||
|
||||
from pathlib import Path
|
||||
from functools import reduce
|
||||
@@ -32,6 +33,7 @@ from troggle.core.models.survex import DrawingFile, Wallet, SurvexBlock, SurvexF
|
||||
from troggle.core.views.scans import oldwallet
|
||||
from troggle.core.views.caves import getCave
|
||||
|
||||
|
||||
from .auth import login_required_if_public
|
||||
#from django.views.decorators.csrf import ensure_csrf_cookie, csrf_exempt
|
||||
|
||||
@@ -225,6 +227,8 @@ def scanupload(request, path=None):
|
||||
'''Upload scanned image files into a wallet on /expofiles
|
||||
Also display AND EDIT the contents.json data in the wallet.
|
||||
|
||||
This is the main wallet display and edit page.
|
||||
|
||||
The Wallet object and the contents.json file are created when the user
|
||||
first uploads files.
|
||||
|
||||
@@ -322,7 +326,9 @@ def scanupload(request, path=None):
|
||||
print(message)
|
||||
return render(request,'errors/generic.html', {'message': message})
|
||||
|
||||
|
||||
def get_logbook_trips():
|
||||
return None
|
||||
|
||||
checkboxes = ["description written", "survex not required", "qms written", "website updated",
|
||||
"plan not required", "plan drawn", "elev not required", "elev drawn", "electronic survey" ]
|
||||
if path:
|
||||
@@ -446,8 +452,9 @@ def scanupload(request, path=None):
|
||||
save_json(waldata)
|
||||
make_wallet(wallet)
|
||||
commit_json(waldata)
|
||||
|
||||
#
|
||||
# Not a POST, so a GET starts here. And also control gets here after a POST is processed.
|
||||
#
|
||||
files = []
|
||||
dirs = []
|
||||
# print(f'! - FORM scanupload - start {wallet} {dirpath}')
|
||||
@@ -482,6 +489,7 @@ def scanupload(request, path=None):
|
||||
chkplannr = ""
|
||||
chkpland = ""
|
||||
svxfiles = []
|
||||
trips =[]
|
||||
checked = {}
|
||||
context = {}
|
||||
if waldata: # should always be true as populated by blank data if json file doesn't exist
|
||||
@@ -584,6 +592,24 @@ def scanupload(request, path=None):
|
||||
if not waldata["description url"]:
|
||||
waldata["description url"]=""
|
||||
|
||||
# find trips and survex files of the same date
|
||||
datestr = waldata["date"].replace('.','-')
|
||||
try:
|
||||
samedate = datetime.date.fromisoformat(datestr)
|
||||
except ValueError:
|
||||
# probably a single digit day number. HACKUS MAXIMUS.
|
||||
# clearly we need to fix this when we first import date strings..
|
||||
datestr = datestr[:-1] + '0' + datestr[-1]
|
||||
print(f' - {datestr=} ')
|
||||
samedate = datetime.date.fromisoformat(datestr)
|
||||
|
||||
trips = LogbookEntry.objects.filter(date=samedate)
|
||||
thisexpo = Expedition.objects.get(year=int(year))
|
||||
expeditionday = thisexpo.get_expedition_day(samedate)
|
||||
#print(f' - {thisexpo=} {expeditionday=}')
|
||||
svxothers = SurvexBlock.objects.filter(expeditionday=expeditionday)
|
||||
#print(f' - {thisexpo=} {expeditionday=} {svxothers=}')
|
||||
|
||||
#Survex and survex complaints, comes from json file on disc, not as pre-populated as above
|
||||
complaints, caveobject = get_complaints([], waldata, svxfiles, files, wallet, wurl)
|
||||
# print(f' - {caveobject=}')
|
||||
@@ -598,6 +624,8 @@ def scanupload(request, path=None):
|
||||
context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty,
|
||||
'files': files, 'dirs': dirs, 'waldata': waldata, 'svxfiles': svxfiles,
|
||||
'checked': checked,
|
||||
'trips': trips,
|
||||
'svxothers': svxothers,
|
||||
'create': create, 'metadataurl': metadataurl,
|
||||
'complaints': complaints,
|
||||
'caveobject': caveobject,
|
||||
|
||||
Reference in New Issue
Block a user