forked from expo/troggle
avoiding problem in KH QMs import
This commit is contained in:
parent
bf1c683fd0
commit
459ed11b58
@ -125,7 +125,7 @@ class Cave(TroggleModel):
|
|||||||
return urljoin(settings.URL_ROOT, reverse('cave',kwargs={'cave_id':href,}))
|
return urljoin(settings.URL_ROOT, reverse('cave',kwargs={'cave_id':href,}))
|
||||||
|
|
||||||
def __str__(self, sep = ": "):
|
def __str__(self, sep = ": "):
|
||||||
return "[Cave:" + str(self.slug()) + "]"
|
return str(self.slug())
|
||||||
|
|
||||||
def get_QMs(self):
|
def get_QMs(self):
|
||||||
return QM.objects.filter(found_by__cave_slug=self.caveslug_set.all())
|
return QM.objects.filter(found_by__cave_slug=self.caveslug_set.all())
|
||||||
|
@ -278,6 +278,8 @@ def usage():
|
|||||||
profile - print the profile from previous runs. Import nothing.
|
profile - print the profile from previous runs. Import nothing.
|
||||||
|
|
||||||
reset - normal usage: clear database and reread everything from files - time-consuming
|
reset - normal usage: clear database and reread everything from files - time-consuming
|
||||||
|
|
||||||
|
init - initialisation. Automatic if you run reset.
|
||||||
caves - read in the caves (must run first after initialisation)
|
caves - read in the caves (must run first after initialisation)
|
||||||
people - read in the people from folk.csv (must run after 'caves')
|
people - read in the people from folk.csv (must run after 'caves')
|
||||||
logbooks - read in the logbooks
|
logbooks - read in the logbooks
|
||||||
@ -312,6 +314,8 @@ if __name__ == "__main__":
|
|||||||
if len(sys.argv)==1:
|
if len(sys.argv)==1:
|
||||||
usage()
|
usage()
|
||||||
exit()
|
exit()
|
||||||
|
elif "init" in sys.argv:
|
||||||
|
jq.enq("reinit",reinit_db)
|
||||||
elif "test" in sys.argv:
|
elif "test" in sys.argv:
|
||||||
jq.enq("caves",import_caves)
|
jq.enq("caves",import_caves)
|
||||||
jq.enq("people",import_people)
|
jq.enq("people",import_people)
|
||||||
|
@ -148,7 +148,7 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_
|
|||||||
for tripperson, time_underground in trippersons:
|
for tripperson, time_underground in trippersons:
|
||||||
lookupAttribs={'personexpedition':tripperson, 'logbook_entry':lbo}
|
lookupAttribs={'personexpedition':tripperson, 'logbook_entry':lbo}
|
||||||
nonLookupAttribs={'time_underground':time_underground, 'is_logbook_entry_author':(tripperson == author)}
|
nonLookupAttribs={'time_underground':time_underground, 'is_logbook_entry_author':(tripperson == author)}
|
||||||
save_carefully(PersonTrip, lookupAttribs, nonLookupAttribs)
|
save_carefully(PersonTrip, lookupAttribs, nonLookupAttribs) # PersonTrip also saved in SetDatesFromLogbookEntries
|
||||||
|
|
||||||
def ParseDate(tripdate, year):
|
def ParseDate(tripdate, year):
|
||||||
""" Interprets dates in the expo logbooks and returns a correct datetime.date object """
|
""" Interprets dates in the expo logbooks and returns a correct datetime.date object """
|
||||||
@ -394,7 +394,7 @@ def SetDatesFromLogbookEntries(expedition):
|
|||||||
lprevpersontrip.save()
|
lprevpersontrip.save()
|
||||||
persontrip.persontrip_next = None
|
persontrip.persontrip_next = None
|
||||||
lprevpersontrip = persontrip
|
lprevpersontrip = persontrip
|
||||||
persontrip.save()
|
persontrip.save() # also saved in EnterLogIntoDbase. MERGE these to speed up import.
|
||||||
|
|
||||||
|
|
||||||
def LoadLogbookForExpedition(expedition,expect):
|
def LoadLogbookForExpedition(expedition,expect):
|
||||||
|
4
utils.py
4
utils.py
@ -62,6 +62,10 @@ def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}):
|
|||||||
print(" !! - -- instance.save()")
|
print(" !! - -- instance.save()")
|
||||||
print(" !! - lookupAttribs:{}\n !! - nonLookupAttribs:{}".format(lookupAttribs,nonLookupAttribs))
|
print(" !! - lookupAttribs:{}\n !! - nonLookupAttribs:{}".format(lookupAttribs,nonLookupAttribs))
|
||||||
raise
|
raise
|
||||||
|
try:
|
||||||
|
msg = str(instance)
|
||||||
|
except:
|
||||||
|
msg = "FAULT getting __str__ for instance with lookupattribs: {}:".format(lookupAttribs)
|
||||||
if created:
|
if created:
|
||||||
logging.info(str(instance) + ' was just added to the database for the first time. \n')
|
logging.info(str(instance) + ' was just added to the database for the first time. \n')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user