2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

contnets.json now visible on form

This commit is contained in:
Philip Sargent 2022-03-15 19:15:45 +00:00
parent 3390f51049
commit 6bdd9be092
2 changed files with 53 additions and 6 deletions

View File

@ -78,11 +78,9 @@ def scanupload(request, wallet=None):
if int(wnumber) == 0:
prev = f'{int(wnumber):02d}'
context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty}
wallet = wallet.replace(':','#')
dirpath = Path(settings.SURVEY_SCANS, year, wallet)
contents_path = dirpath / contentsjson
walletdata = dirpath / contentsjson
form = FilesForm()
@ -105,7 +103,6 @@ def scanupload(request, wallet=None):
# Wallet folder created, but index and contents.json need to be created.
contents_path = dirpath / contentsjson
if not contents_path.is_file(): # double-check
with open(contents_path, "w") as json_file:
json.dump(wallet_blank_json, json_file, sort_keys=True, indent = 1)
@ -139,8 +136,33 @@ def scanupload(request, wallet=None):
if dirs:
dirs = sorted(dirs)
waldata = []
if contents_path.is_file():
with open(contents_path) as json_file:
try:
waldata = json.load(json_file)
except:
message = f"! Failed to load {contents_path} JSON file"
print(message)
DataIssue.objects.create(parser='Scans', message=message)
raise
if not waldata["people"]:
waldata["people"]=["NOBODY"]
if waldata["cave"]:
cave = waldata["cave"]
if waldata["name"]:
psg = waldata["name"]
if waldata["survex file"]:
if not isinstance(waldata["survex file"], list):
waldata["survex file"] = [waldata["survex file"]]
context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty,
'files': files, 'dirs': dirs, 'waldata': waldata, 'create': create,
'filesaved': filesaved, 'actual_saved': actual_saved }
return render(request, 'scanuploadform.html',
{'form': form, 'wallet': wallet, **context, 'files': files, 'dirs': dirs, 'create': create, 'filesaved': filesaved, 'actual_saved': actual_saved})
{'form': form, 'wallet': wallet, **context, 'cave': cave, 'psg': psg})
@login_required_if_public
def photoupload(request, folder=None):

View File

@ -57,4 +57,29 @@
</div>
<hr />
<br>
<span style="font-family: monospace; font-size: 150%; ">
{% if cave %}<u>Cave ID</u>: <b>{{cave}}</b><br> {% endif %}
{% if psg %}<u>Survey area</u>: <b>{{psg}}</b><br><br> {% endif %}
</span>
<span style="font-family: monospace; font-size: 130%; ">
<table style="border: 1px; border-style: hidden;>
{% for d, value in waldata.items %}
<tr style="border-style: hidden;">
<td style="border-style: hidden; padding-right: 3em;">{{d}}</td>
{% if d == "survex file" %}
<td>
{% for svx in value %}
<a href="/survexfile/{{svx}}">{{svx}}</a>
{% endfor %}
</td>
{% else %}
<td> <b>{{value}}</b></td>
{% endif %}
</tr>
{% empty %}
<p>&lt;No JSON data here&gt;
{% endfor %}
</table>
</span>
{% endblock %}