diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2022-07-06 15:38:53 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2022-07-06 15:38:53 +0300 |
commit | 7dc3cc3b91e0c8dff87ccc09a73421ab64c2a919 (patch) | |
tree | d9e2526ba9af54687a18c3bf9b0858f9b63ba368 /parsers/QMs.py | |
parent | ee4237b14cd831114f8a3a787fc908f62e72f4a4 (diff) | |
download | troggle-7dc3cc3b91e0c8dff87ccc09a73421ab64c2a919.tar.gz troggle-7dc3cc3b91e0c8dff87ccc09a73421ab64c2a919.tar.bz2 troggle-7dc3cc3b91e0c8dff87ccc09a73421ab64c2a919.zip |
fix for individual QM display from survex
Diffstat (limited to 'parsers/QMs.py')
-rw-r--r-- | parsers/QMs.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/parsers/QMs.py b/parsers/QMs.py index ca6583b..ab9ec0f 100644 --- a/parsers/QMs.py +++ b/parsers/QMs.py @@ -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 |