forked from expo/troggle
creating new wallet now copies nd commits
This commit is contained in:
parent
93622b111f
commit
c29e240c2b
@ -23,12 +23,12 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
|
|||||||
#from troggle import settings
|
#from troggle import settings
|
||||||
from troggle.parsers.imports import import_caves, import_people, import_surveyscans
|
from troggle.parsers.imports import import_caves, import_people, import_surveyscans
|
||||||
from troggle.parsers.imports import import_logbooks, import_QMs, import_drawingsfiles, import_survex
|
from troggle.parsers.imports import import_logbooks, import_QMs, import_drawingsfiles, import_survex
|
||||||
from troggle.parsers.scans import wallet_blank_json, wallet_blank_html, contentsjson, indexhtml
|
from troggle.parsers.scans import wallet_blank_json, wallet_blank_html, contentsjson, indexhtml, CopyWalletData
|
||||||
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
|
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
|
||||||
from troggle.core.models.troggle import DataIssue
|
from troggle.core.models.troggle import DataIssue
|
||||||
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
|
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
|
||||||
from troggle.core.models.caves import LogbookEntry, QM, Cave, PersonTrip
|
from troggle.core.models.caves import LogbookEntry, QM, Cave, PersonTrip
|
||||||
from troggle.core.models.survex import DrawingFile
|
from troggle.core.models.survex import DrawingFile, Wallet
|
||||||
from troggle.core.views.scans import oldwallet, walletindex
|
from troggle.core.views.scans import oldwallet, walletindex
|
||||||
from troggle.core.views.caves import getCave
|
from troggle.core.views.caves import getCave
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ xlate = {"url": "description url",
|
|||||||
"electronic": "electronic survey",
|
"electronic": "electronic survey",
|
||||||
"pland": "plan drawn",
|
"pland": "plan drawn",
|
||||||
"elevd": "elev drawn",
|
"elevd": "elev drawn",
|
||||||
"psg": "name", # not real ?
|
"psg": "name", # a name for this wallet
|
||||||
"survex": "survex file",
|
"survex": "survex file",
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +115,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
|
|||||||
if not type(waldata["survex file"])==list: # a string also is a sequence type, so do it this way
|
if not type(waldata["survex file"])==list: # a string also is a sequence type, so do it this way
|
||||||
waldata["survex file"] = [waldata["survex file"]]
|
waldata["survex file"] = [waldata["survex file"]]
|
||||||
for svx in waldata["survex file"]:
|
for svx in waldata["survex file"]:
|
||||||
|
if svx !="":
|
||||||
svxfiles.append(svx)
|
svxfiles.append(svx)
|
||||||
if not (Path(settings.SURVEX_DATA) / svx).is_file():
|
if not (Path(settings.SURVEX_DATA) / svx).is_file():
|
||||||
file_complaint = f"{wallet} Incorrect survex file name in wallet data: {svx} not found in LOSER repo"
|
file_complaint = f"{wallet} Incorrect survex file name in wallet data: {svx} not found in LOSER repo"
|
||||||
@ -290,6 +291,21 @@ def scanupload(request, path=None):
|
|||||||
with open(contents_path, "w") as jfile:
|
with open(contents_path, "w") as jfile:
|
||||||
json.dump(wd, jfile, indent = 1)
|
json.dump(wd, jfile, indent = 1)
|
||||||
# print(f'--- FINISHED saving to JSON\n')
|
# print(f'--- FINISHED saving to JSON\n')
|
||||||
|
|
||||||
|
# This copies the new data to the drawings repo and commit it
|
||||||
|
# needs the troggle object wallet, not a string
|
||||||
|
|
||||||
|
try:
|
||||||
|
w, created = Wallet.objects.get_or_create(walletname=wallet)
|
||||||
|
print(f'wallet string {wallet}, wallet object {w} created new?: {created}')
|
||||||
|
if created:
|
||||||
|
w.fpath = Path(settings.SCANS_ROOT, wallet[0:4], wallet)
|
||||||
|
w.save()
|
||||||
|
CopyWalletData(w)
|
||||||
|
except:
|
||||||
|
print(f'wallet string {wallet}, FAIL TO GET WALLET OBJECT, maybe we need to create it ?')
|
||||||
|
raise
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(f'--- INVALID JSON Update form submitted')
|
print(f'--- INVALID JSON Update form submitted')
|
||||||
print(formj.errors)
|
print(formj.errors)
|
||||||
|
@ -80,6 +80,8 @@ def LoadListScansFile(wallet):
|
|||||||
c = 0
|
c = 0
|
||||||
def CopyWalletData(wallet):
|
def CopyWalletData(wallet):
|
||||||
'''Copies all the contents.json to a parallel set of folders in the drawings repo
|
'''Copies all the contents.json to a parallel set of folders in the drawings repo
|
||||||
|
refreshes everything during a ful import, but it shoudl all be up to date as every time
|
||||||
|
wallet data gets saved it should also be copied across and committed.
|
||||||
'''
|
'''
|
||||||
year = wallet.walletname[0:4]
|
year = wallet.walletname[0:4]
|
||||||
destfolder = Path(settings.DRAWINGS_DATA,'walletjson', year, wallet.walletname)
|
destfolder = Path(settings.DRAWINGS_DATA,'walletjson', year, wallet.walletname)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user