From 9410dda69ef4bdae206f4b56b22e77eb2e5845aa Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 14 Sep 2022 00:31:37 +0300 Subject: [PATCH] List the logbook trips and other svx files of the same date --- core/views/uploads.py | 32 +++++++++++++++++++++-- templates/walletform.html | 53 +++++++++++++++++++++++++-------------- 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/core/views/uploads.py b/core/views/uploads.py index 336ffe7..fbe1da1 100644 --- a/core/views/uploads.py +++ b/core/views/uploads.py @@ -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, diff --git a/templates/walletform.html b/templates/walletform.html index c32ba8a..d9427e9 100644 --- a/templates/walletform.html +++ b/templates/walletform.html @@ -109,31 +109,17 @@ {% endif %} {% endif %} {% if psg %}Survey area: {{psg}}
{% endif %} - {% if svxfiles %}Survey files: - {% for svx in svxfiles%} + {% if svxfiles %}Survex files: + {% for svx in svxfiles %} {{svx}} {% endfor %} - -
+
{% endif %} - {% if metadataurl %}Debug: json file
{% endif %} + - +