mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 05:37:13 +00:00
wallets & caves now many:many
This commit is contained in:
@@ -23,7 +23,7 @@ from troggle.core.models.troggle import DataIssue, Expedition
|
||||
from troggle.core.models.wallets import Wallet, YEAR_RANGE, make_valid_date
|
||||
|
||||
from troggle.core.views.auth import login_required_if_public
|
||||
from troggle.core.views.caves import getCave
|
||||
from troggle.core.views.caves import getCave, get_cave_leniently
|
||||
from troggle.core.views.scans import caveifywallet, oldwallet
|
||||
from troggle.core.views.uploads import FilesForm
|
||||
|
||||
@@ -108,7 +108,8 @@ xlate = {
|
||||
"survex": "survex file",
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
|
||||
"""Taken from old script wallets.py and edited to make more comprehensible
|
||||
Loads the survex files names and processes all complaints
|
||||
@@ -231,20 +232,29 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
|
||||
)
|
||||
|
||||
# Find the cave, if it exists
|
||||
# Just for wallets, we are lenient about whether the 1623- prefix has been written down.
|
||||
if waldata["cave"]:
|
||||
caveobject = None
|
||||
try:
|
||||
caveid = waldata["cave"]
|
||||
if type(caveid) is list:
|
||||
for i in caveid:
|
||||
i = i.replace("/", "-")
|
||||
caveobject = getCave(i) # only the last one gets recorded.. ouch.
|
||||
caveobject = get_cave_leniently(i)
|
||||
w.caves.add(caveobject) # new many-to-many field
|
||||
#print(w.caves)
|
||||
else:
|
||||
caveid = caveid # ?urk? why?
|
||||
try:
|
||||
caveobject = getCave(caveid) # may fail if garbage value ,e.g. space, in wallet data
|
||||
except:
|
||||
caveobject = None
|
||||
print(f'getCave for id "{waldata["cave"]}" {caveobject}')
|
||||
# either single cave or the square barckets have been removed
|
||||
ids = caveid.split(",")
|
||||
for i in ids:
|
||||
j = i.replace("'","").strip('[] "')
|
||||
#print(j)
|
||||
try:
|
||||
caveobject = get_cave_leniently(j) # may fail if garbage value ,e.g. space, in wallet data
|
||||
w.caves.add(caveobject)
|
||||
except:
|
||||
pass
|
||||
print(f'get_cave_leniently from "{waldata["cave"]}" => {caveobject}')
|
||||
# if not caveobject.url == waldata["description url"]:
|
||||
# complaints.append(f'The URL of cave description \"{waldata["description url"]}\" does not match the one on record for this cave which is: "{caveobject.url}". If the wallet is not for a cave, put a useful URL here.')
|
||||
except Cave.MultipleObjectsReturned:
|
||||
|
||||
Reference in New Issue
Block a user