summaryrefslogtreecommitdiffstats
path: root/parsers
diff options
context:
space:
mode:
Diffstat (limited to 'parsers')
-rw-r--r--parsers/QMs.py20
-rw-r--r--parsers/survex.py5
2 files changed, 17 insertions, 8 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
diff --git a/parsers/survex.py b/parsers/survex.py
index 1390991..fa92924 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -557,8 +557,8 @@ class LoadingSurvex():
entry_type="DUMMY",
expedition_id=1,
defaults={"date": survexblock.date,"cave_slug":caveslug, "slug": logslug})
- print(insp+message)
- DataIssue.objects.create(parser='survex', message=message)
+ # print(insp+message)
+ # DataIssue.objects.create(parser='survex', message=message)
try:
qm = QM.objects.create(number=qm_no,
@@ -569,6 +569,7 @@ class LoadingSurvex():
location_description=qm_notes,
blockname = blockname, # only set for survex-imported QMs
found_by = placeholder,
+ expoyear = str(survexblock.date.year),
cave = survexblock.survexfile.cave)
qm.save
# message = " ! QM{} '{}' CREATED in DB in '{}'".format(qm_no, qm_nearest,survexblock.survexfile.path)