diff options
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 |