2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-13 20:47:08 +00:00

fix for individual QM display from survex

This commit is contained in:
Philip Sargent
2022-07-06 15:38:53 +03:00
parent ee4237b14c
commit 7dc3cc3b91
5 changed files with 83 additions and 54 deletions

View File

@@ -103,14 +103,17 @@ def parseCaveQMs(cave,inputFile):
newQM.comment=line[6]
try:
# year and number are unique for a cave in CSV imports
preexistingQM=QM.objects.get(number=QMnum, found_by__date__year=year) #if we don't have this one in the DB, save it
if preexistingQM.new_since_parsing==False: #if the pre-existing QM has not been modified, overwrite it
if preexistingQM.new_since_parsing==False: #if the pre-existing QM has not been modified, overwrite it - VERY OLD THING
preexistingQM.delete()
newQM.expoyear = year
newQM.save()
else: # otherwise, print that it was ignored
print((" - preserving " + str(preexistingQM) + ", which was edited in admin \r"))
except QM.DoesNotExist: #if there is no pre-existing QM, save the new one
newQM.expoyear = year
newQM.save()
nqms += 1
except KeyError: #check on this one
@@ -143,17 +146,22 @@ def parse_KH_QMs(kh, inputFile):
# print(message)
# DataIssue.objects.create(parser='QMs', message=message)
lookupArgs={
# inadequate now that the sequence numbers are not unique for survex-parsed QMs
'found_by':placeholder,
'number':res['number']
'expoyear':year,
'number':res['number'],
'cave': kh,
'grade':res['grade']
}
nonLookupArgs={
'cave': kh,
'grade':res['grade'],
'nearest_station_name':res['nearest_station'],
'location_description':res['description']
}
save_carefully(QM,lookupArgs,nonLookupArgs)
instance, created = save_carefully(QM,lookupArgs,nonLookupArgs)
if created:
message = " ! - "+ instance.code() + " QM entry for '161 KH' created. "
print(message)
DataIssue.objects.create(parser='QMs', message=message)
nqms += 1
return nqms