mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 13:07:11 +00:00
renamed form and more comments
This commit is contained in:
@@ -33,7 +33,7 @@ from troggle.core.utils import (
|
|||||||
from troggle.core.views.auth import login_required_if_public
|
from troggle.core.views.auth import login_required_if_public
|
||||||
from troggle.core.views.caves import get_cave_leniently, getCave
|
from troggle.core.views.caves import get_cave_leniently, getCave
|
||||||
from troggle.core.views.scans import caveifywallet, oldwallet
|
from troggle.core.views.scans import caveifywallet, oldwallet
|
||||||
from troggle.core.views.uploads import FilesForm
|
from troggle.core.views.uploads import WalletFilesForm
|
||||||
from troggle.parsers.scans import CONTENTSJSON
|
from troggle.parsers.scans import CONTENTSJSON
|
||||||
|
|
||||||
"""Main wallet editing form, which includes scan file upload into the wallet
|
"""Main wallet editing form, which includes scan file upload into the wallet
|
||||||
@@ -680,9 +680,11 @@ def walletedit(request, path=None):
|
|||||||
fresh_wallet = False
|
fresh_wallet = False
|
||||||
|
|
||||||
editor = get_cookie(request)
|
editor = get_cookie(request)
|
||||||
form = FilesForm()
|
form = WalletFilesForm()
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
# There are two forms on this page, we don't know which one it is yet.
|
||||||
|
# Actually there are three.. this all needs refactoring to be easier to read and understand.
|
||||||
# print(f'--- POST processing starts {wallet=} {path=}')
|
# print(f'--- POST processing starts {wallet=} {path=}')
|
||||||
if "psg" in request.POST: # handle metadata form
|
if "psg" in request.POST: # handle metadata form
|
||||||
formj = WalletForm(request.POST)
|
formj = WalletForm(request.POST)
|
||||||
@@ -748,7 +750,7 @@ def walletedit(request, path=None):
|
|||||||
|
|
||||||
return HttpResponseRedirect(f'/walletedit/{walletgoto.replace("#",":")}')
|
return HttpResponseRedirect(f'/walletedit/{walletgoto.replace("#",":")}')
|
||||||
|
|
||||||
else: # Creating a wallet .
|
else: # Creating a wallet or uploading files
|
||||||
# NOT editing wallet data, or uploading a file. Should not overwrite metadata at all.
|
# NOT editing wallet data, or uploading a file. Should not overwrite metadata at all.
|
||||||
if "submitbutton" in request.POST:
|
if "submitbutton" in request.POST:
|
||||||
print(f"--- Submit button value {request.POST['submitbutton']}")
|
print(f"--- Submit button value {request.POST['submitbutton']}")
|
||||||
@@ -758,9 +760,11 @@ def walletedit(request, path=None):
|
|||||||
walletobject = make_wallet(wallet) # no date set yet
|
walletobject = make_wallet(wallet) # no date set yet
|
||||||
commit_json(w)
|
commit_json(w)
|
||||||
|
|
||||||
form = FilesForm(request.POST, request.FILES)
|
form = WalletFilesForm(request.POST, request.FILES)
|
||||||
if form.is_valid():
|
if not form.is_valid():
|
||||||
# print(f'--- FORM walletedit multiple BUT EMPTY METADATA supposedly {WALLET_BLANK_JSON["date"]=}')
|
print("--- Upload <files form> is invalid, which is correct if just created as there are no files.")
|
||||||
|
else:
|
||||||
|
print(f'--- FORM walletedit multiple BUT EMPTY METADATA supposedly {WALLET_BLANK_JSON["date"]=}')
|
||||||
multiple = request.FILES.getlist("uploadfiles")
|
multiple = request.FILES.getlist("uploadfiles")
|
||||||
fs = FileSystemStorage(os.path.join(dirpath)) # creates wallet folder if necessary
|
fs = FileSystemStorage(os.path.join(dirpath)) # creates wallet folder if necessary
|
||||||
|
|
||||||
@@ -777,12 +781,14 @@ def walletedit(request, path=None):
|
|||||||
actual_saved.append(saved_filename)
|
actual_saved.append(saved_filename)
|
||||||
# print(f'! - FORM walletedit multiple {actual_saved}')
|
# print(f'! - FORM walletedit multiple {actual_saved}')
|
||||||
filesaved = True
|
filesaved = True
|
||||||
|
message = f"FAILED to save file {f.name} as {saved_filename}. Please report this error."
|
||||||
|
else:
|
||||||
|
message = f"FAILED to save file {f.name}. Please report this error."
|
||||||
|
return render(request, "errors/generic.html", {"message": message})
|
||||||
# print(f'--- FORM walletedit multiple BUT EMPTY METADATA supposedly {WALLET_BLANK_JSON["date"]=}')
|
# print(f'--- FORM walletedit multiple BUT EMPTY METADATA supposedly {WALLET_BLANK_JSON["date"]=}')
|
||||||
save_json(waldata)
|
save_json(waldata)
|
||||||
walletobject = make_wallet(wallet)
|
walletobject = make_wallet(wallet)
|
||||||
commit_json(waldata)
|
commit_json(waldata)
|
||||||
else:
|
|
||||||
print("--- Upload files form invalid, which is correct if just created.")
|
|
||||||
#
|
#
|
||||||
# Not a POST, so a GET starts here. And also control gets here after a POST is processed.
|
# Not a POST, so a GET starts here. And also control gets here after a POST is processed.
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user