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

use new upload page for most wallets

This commit is contained in:
Philip Sargent 2022-03-18 11:28:35 +00:00
parent e4ee4abce8
commit af7fc8f243
5 changed files with 145 additions and 121 deletions

View File

@ -20,11 +20,14 @@ need to check if inavlid query string is invalid, or produces multiple replies
and render a user-friendly error page.
'''
def singlewallet(request, path):
#print [ s.walletname for s in Wallet.objects.all() ]
def oldwallet(request, path):
'''Now called only for non-standard wallet structures for pre-2000 wallets
'''
# print([ s.walletname for s in Wallet.objects.all() ])
print(f'! - oldwallet path:{path}')
try:
wallet = Wallet.objects.get(walletname=urlunquote(path))
return render(request, 'wallet.html', { 'wallet':wallet, 'settings': settings })
return render(request, 'wallet_old.html', { 'wallet':wallet, 'settings': settings })
except:
message = f'Scan folder error or not found \'{path}\' .'
return render(request, 'errors/generic.html', {'message': message})

View File

@ -2,6 +2,7 @@ import re, os
import subprocess
import json
import settings
import urllib
from pathlib import Path
@ -15,6 +16,7 @@ from django.shortcuts import render
from django.template import Context, loader
from django.core.files.storage import FileSystemStorage, default_storage
#from troggle import settings
from troggle.parsers.imports import import_caves, import_people, import_surveyscans
from troggle.parsers.imports import import_logbooks, import_QMs, import_drawingsfiles, import_survex
@ -24,6 +26,8 @@ from troggle.core.models.troggle import DataIssue
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.models.caves import LogbookEntry, QM, Cave, PersonTrip
from troggle.core.models.survex import DrawingFile
from troggle.core.views.scans import oldwallet
from .auth import login_required_if_public
#from django.views.decorators.csrf import ensure_csrf_cookie, csrf_exempt
@ -88,7 +92,7 @@ xlate = {"url": "description url",
}
@login_required_if_public
def scanupload(request, wallet=None):
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.
@ -100,14 +104,22 @@ def scanupload(request, wallet=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:
wallet = urllib.parse.unquote(path)
else:
wallet = "2022#01" # improve this later
# print(f'! - FORM scanupload - start {wallet}')
if wallet is None:
wallet = "2021#01" # improve this later
if not re.match('(19|20)\d\d:\d\d', wallet):
wallet = "2021:01" # improve this later
year = wallet[:4]
if int(year) <= 1999:
print(f'! - FORM scanupload - start {wallet} REDIRECT TO OLDWALLET')
return(oldwallet(request, path))
if not re.match('(19|20)\d\d[:#]\d\d', wallet):
wallet = "2022:01" # improve this later
print(f'! - FORM scanupload - start {wallet}')
if path:
print(f'! - FORM scanupload - start wallet:{wallet}: path:{path}:')
if int(year) < 1977:
year = "1977"
if int(year) > 2050:
@ -115,6 +127,7 @@ def scanupload(request, wallet=None):
nexty = f'{int(year)+1}'
prevy = f'{int(year)-1}'
wnumber = wallet[5:]
next = f'{int(wnumber)+1:02d}'
prev = f'{int(wnumber)-1:02d}'

View File

@ -57,107 +57,109 @@
</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>{% endif %}
{% if svxfiles %}<u>Survey files</u>:
{% for svx in svxfiles%}
<a href="/survexfile/{{svx}}">{{svx}}</a>
{% endfor %}
{% if not create %}
<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>{% endif %}
{% if svxfiles %}<u>Survey files</u>:
{% for svx in svxfiles%}
<a href="/survexfile/{{svx}}">{{svx}}</a>
{% endfor %}
<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>
<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>
<td> <b>{{value}}</b></td>
<td> <b>{{value}}</b></td>
</tr>
{% empty %}
<p>&lt;No JSON data here&gt;
{% endfor %}
</table>
-->
</span>
<style>
input {font-family: monospace; font-weight: bold; font-size: 100%; padding: 0.5em; }
</style>
<div style = "max-width:100%; margin-left:15%; font-family: monospace; font-weight: bold; font-size: 150%; text-align: right; " >
<form method ='post'>
{% csrf_token %}
<label for="date">Date of the survey trip</label>
<input
label = "Date" name = "date" size="12"
title="Date of the trip in ISO format: 2020-08-17"
placeholder="{{date}}" value="{{date}}" required />
<br>
<label for="cave">Cave ID</label>
<input
label = "Cave" name = "cave" size="12"
title="Cave id e.g. 2017-DM-01 or 1623/256"
placeholder="{{cave}}" value="{{cave}}" />
<br>
<label for="psg">Survey area</label>
<input
label = "Survey area" name = "psg" size ="{{psgsize}}"
title="Survey area, e.g. White Elephant or Nieder Augst Eck"
placeholder="{{psg}}" value="{{psg}}" />
<br>
<label for="plannr">Plan not required ?</label>
<input type="checkbox" name="plannr" id="plannr" value=" True" {% if "plan not required" in checked %}checked{% endif %}>
<br>
<label for="elevnr">Elevation not required ?</label>
<input type="checkbox" name="elevnr" id="elevnr" value="True" {% if "elev not required" in checked %}checked{% endif %}>
<br>
<label for="survexvnr">Survex file not required ?</label>
<input type="checkbox" name="survexvnr" id="survexvnr" value="True" {% if "survex not required" in checked %}checked{% endif %}>
<br>
<label for="pland">Plan drawn ?</label>
<input type="checkbox" name="pland" id="pland" value="True" {{chkpland}} {% if "plan drawn" in checked %}checked{% endif %}>
<br>
<label for="elevd">Elevation drawn ?</label>
<input type="checkbox" name="elevd" id="elevd" value="True" {% if "elev drawn" in checked %}checked{% endif %}>
<br>
<label for="descriptionw">Cave description written ?</label>
<input type="checkbox" name="descriptionw" id="descriptionw" value="True" {% if "description written" in checked %}checked{% endif %}>
<br>
<label for="qmsw">QMs written ?</label>
<input type="checkbox" name="qmsw" id="qmsw" value="True" {% if "qms written" in checked %}checked{% endif %}>
<br>
<label for="websiteupt">Website updated ?</label>
<input type="checkbox" name="websiteupt" id="websiteupt" value="True" {% if "website updated" in checked %}checked{% endif %}>
<br>
<label for="electronic">Electronic survey ?</label>
<input type="checkbox" name="electronic" id="electronic" value="True" {% if "electronic survey" in checked %}checked{% endif %}>
<br>
<label for="people">List of people on the survey trip</label>
<input
label = "People" name = "people" size ="{{peoplesize}}"
title="List of people on the survey trip"
placeholder="{{people}}" value="{{people}}" />
<br>
<label for="url">URL of cave description</label>
<input
label = "URL" name = "url" size ="{{urlsize}}"
title="URL of cave description, e.g. /1623/264/264.html"
placeholder="{{url}}" value="{{url}}" />
<br>
<label for="survex">List of survex files</label>
<input
label = "survex" name = "survex" size ="{{survexsize}}"
title="List of survex files using this data"
placeholder="{{survex}}" value="{{survex}}" />
<br><br>
<button class="fancybutton" style="padding: 0.5em 25px; margin-left: 155px; font-size: 90%; "
type = "submit" value = "Edit" >
Submit changes
</button>
</form>
</div>
</tr>
{% empty %}
<p>&lt;No JSON data here&gt;
{% endfor %}
</table>
-->
</span>
<style>
input {font-family: monospace; font-weight: bold; font-size: 100%; padding: 0.5em; }
</style>
<div style = "max-width:100%; margin-left:15%; font-family: monospace; font-weight: bold; font-size: 150%; text-align: right; " >
<form method ='post'>
{% csrf_token %}
<label for="date">Date of the survey trip</label>
<input
label = "Date" name = "date" size="12"
title="Date of the trip in ISO format: 2020-08-17"
placeholder="{{date}}" value="{{date}}" required />
<br>
<label for="cave">Cave ID</label>
<input
label = "Cave" name = "cave" size="12"
title="Cave id e.g. 2017-DM-01 or 1623/256"
placeholder="{{cave}}" value="{{cave}}" />
<br>
<label for="psg">Survey area</label>
<input
label = "Survey area" name = "psg" size ="{{psgsize}}"
title="Survey area, e.g. White Elephant or Nieder Augst Eck"
placeholder="{{psg}}" value="{{psg}}" />
<br>
<label for="plannr">Plan not required ?</label>
<input type="checkbox" name="plannr" id="plannr" value=" True" {% if "plan not required" in checked %}checked{% endif %}>
<br>
<label for="elevnr">Elevation not required ?</label>
<input type="checkbox" name="elevnr" id="elevnr" value="True" {% if "elev not required" in checked %}checked{% endif %}>
<br>
<label for="survexvnr">Survex file not required ?</label>
<input type="checkbox" name="survexvnr" id="survexvnr" value="True" {% if "survex not required" in checked %}checked{% endif %}>
<br>
<label for="pland">Plan drawn ?</label>
<input type="checkbox" name="pland" id="pland" value="True" {{chkpland}} {% if "plan drawn" in checked %}checked{% endif %}>
<br>
<label for="elevd">Elevation drawn ?</label>
<input type="checkbox" name="elevd" id="elevd" value="True" {% if "elev drawn" in checked %}checked{% endif %}>
<br>
<label for="descriptionw">Cave description written ?</label>
<input type="checkbox" name="descriptionw" id="descriptionw" value="True" {% if "description written" in checked %}checked{% endif %}>
<br>
<label for="qmsw">QMs written ?</label>
<input type="checkbox" name="qmsw" id="qmsw" value="True" {% if "qms written" in checked %}checked{% endif %}>
<br>
<label for="websiteupt">Website updated ?</label>
<input type="checkbox" name="websiteupt" id="websiteupt" value="True" {% if "website updated" in checked %}checked{% endif %}>
<br>
<label for="electronic">Electronic survey ?</label>
<input type="checkbox" name="electronic" id="electronic" value="True" {% if "electronic survey" in checked %}checked{% endif %}>
<br>
<label for="people">List of people on the survey trip</label>
<input
label = "People" name = "people" size ="{{peoplesize}}"
title="List of people on the survey trip"
placeholder="{{people}}" value="{{people}}" />
<br>
<label for="url">URL of cave description</label>
<input
label = "URL" name = "url" size ="{{urlsize}}"
title="URL of cave description, e.g. /1623/264/264.html"
placeholder="{{url}}" value="{{url}}" />
<br>
<label for="survex">List of survex files</label>
<input
label = "survex" name = "survex" size ="{{survexsize}}"
title="List of survex files using this data"
placeholder="{{survex}}" value="{{survex}}" />
<br><br>
<button class="fancybutton" style="padding: 0.5em 25px; margin-left: 155px; font-size: 90%; "
type = "submit" value = "Edit" >
Submit changes
</button>
</form>
</div>
{% endif %} <!-- not create -->
{% endblock %}

View File

@ -2,7 +2,9 @@
{% block title %}Survey Scans Wallet {% endblock %}
{% block content %}
<h3>Survey Scans in: {{wallet.walletname}}</h3>
<h3>Survey Scans in old wallet: {{wallet.walletname}}</h3>
<p>Wallets of 1999 and earlier are in a different structure and have not yet been edited to conform to the current
name format and folder structure.
<table>
{% for singlescan in wallet.singlescan_set.all %}
<tr>
@ -17,7 +19,9 @@
</table>
<h3>Survex surveys referring to this wallet</h3>
<p><b>*ref</b> references have not been configured in most old survex files,
so it is unlikley that you will see anything here. To find survex files for this year look in the
survex column of the <a href="/expedition/1999">expedition page</a>.
<table>
{% for survexblock in wallet.survexblock_set.all %}
<tr>

20
urls.py
View File

@ -8,7 +8,7 @@ from django.contrib import auth
from django.urls import path, reverse, resolve
from troggle.core.views import caves, statistics, survex
from troggle.core.views.scans import scansingle, singlewallet, allwallets
from troggle.core.views.scans import scansingle, allwallets
from troggle.core.views.drawings import dwgallfiles, dwgfilesingle
from troggle.core.views.uploads import dwgupload, scanupload, photoupload
from troggle.core.views.other import troggle404, frontpage, todos, controlpanel, frontpage
@ -86,7 +86,8 @@ trogglepatterns = [
re_path(r'^admin/', admin.site.urls), # includes admin login & logout urls
# Uploads - uploading a file
path('scanupload/<wallet>', scanupload, name='scanupload'), # wallet=2020#01, not a path
path('scanupload/', scanupload, name='scanupload'), # path=2020#01
path('scanupload/<path:path>', scanupload, name='scanupload'), # path=2020#01
path('photoupload/', photoupload, name='photoupload'), # restricted to current year
path('photoupload/<path:folder>', photoupload, name='photoupload'), # restricted to current year
path('dwgupload/<path:folder>', dwgupload, name='dwgupload'),
@ -94,7 +95,8 @@ trogglepatterns = [
path('dwguploadnogit/', dwgupload, {'gitdisable': 'yes'}, name='dwguploadnogit'), # used in testing
path('dwguploadnogit/<path:folder>', dwgupload, {'gitdisable': 'yes'}, name='dwguploadnogit'), # used in testing
# setting LOGIN_URL = '/accounts/login/' is default
# setting LOGIN_URL = '/accounts/login/' is default.
# NB setting url pattern name to 'login' instea dof 'expologin' with override Django, see https://docs.djangoproject.com/en/4.0/topics/http/urls/#naming-url-patterns
path('accounts/logout/', expologout, name='expologout'), # same as in django.contrib.auth.urls
path('accounts/login/', expologin, name='expologin'), # same as in django.contrib.auth.urls
#re_path(r'^accounts/', include('django.contrib.auth.urls')), # see site-packages\registration\auth_urls_classes.py
@ -124,13 +126,13 @@ trogglepatterns = [
re_path(r'^newcave/$', caves.edit_cave, name="newcave"),
re_path(r'^cave/3d/(?P<cave_id>[^/]+)$', caves.cave3d, name="cave3d"),
re_path(r'^cave/description/([^/]+)/?$', caves.caveDescription),
re_path(r'^cave/description/([^/]+)/?$', caves.caveDescription), #!!!BAD, local links fail..
re_path(r'^cave/(?P<cave_id>[^/]+)/?$', caves.cave, name="cave"), #!!!BAD, local links fail.. to be checked..
re_path(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), # view_caves.ent
re_path(r'^cave/(?P<slug>[^/]+)/edit/$', caves.edit_cave, name="edit_cave"),
re_path(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), #!!!BAD, local links fail..# view_caves.ent
re_path(r'^cave/(?P<slug>[^/]+)/edit/$', caves.edit_cave, name="edit_cave"),
re_path(r'^(?P<karea>\d\d\d\d)(?P<subpath>.*)$', cavepage, name="cavepage"), # shorthand /1623/264 BUT url links break! Stop this..
# Note that urls eg '1623/161/l/rl89a.htm' are handled by cavepage which redirects them to 'expopage'
# Note that _edit$ for a cave description page in a subfolder e.g. /1623/via204.html_edit gets caught here and breaks with 404
# Note that urls eg '/1623/161/l/rl89a.htm' are handled by cavepage which redirects them to 'expopage'
# Note that _edit$ for a cave description page in a subfolder e.g. /1623/204/204.html_edit gets caught here and breaks with 404
# Entrances
re_path(r'^cave/entrance/([^/]+)/?$', caves.caveEntrance), # lists all entrances !!!BAD, local links fail
@ -163,7 +165,7 @@ trogglepatterns = [
# The survey scans in the wallets
path('survey_scans/', allwallets, name="allwallets"),
path('survey_scans/<path:path>/', singlewallet, name="singlewallet"),
path('survey_scans/<path:path>/', scanupload, name="singlewallet"), # replaced singlewallet()
path('survey_scans/<path:path>/<file>', scansingle, name="scansingle"),
# The tunnel and therion drawings files pages