mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-14 05:55:06 +00:00
bug fixed for new logbook
This commit is contained in:
@@ -108,15 +108,12 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_
|
|||||||
lookupAttribs={'date':date, 'title':title}
|
lookupAttribs={'date':date, 'title':title}
|
||||||
nonLookupAttribs={'place':place, 'text':text, 'expedition':expedition, 'cave':cave, 'slug':slugify(title)[:50], 'entry_type':entry_type}
|
nonLookupAttribs={'place':place, 'text':text, 'expedition':expedition, 'cave':cave, 'slug':slugify(title)[:50], 'entry_type':entry_type}
|
||||||
lbo, created=save_carefully(models.LogbookEntry, lookupAttribs, nonLookupAttribs)
|
lbo, created=save_carefully(models.LogbookEntry, lookupAttribs, nonLookupAttribs)
|
||||||
#logentries.append(models.LogbookEntry)
|
|
||||||
|
|
||||||
|
|
||||||
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(models.PersonTrip, lookupAttribs, nonLookupAttribs)
|
save_carefully(models.PersonTrip, lookupAttribs, nonLookupAttribs)
|
||||||
#logentries.append(models.PersonTrip)
|
|
||||||
|
|
||||||
|
|
||||||
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 """
|
||||||
@@ -350,6 +347,27 @@ def LoadLogbookForExpedition(expedition):
|
|||||||
parsefunc = year_settings[1]
|
parsefunc = year_settings[1]
|
||||||
logbook_parseable = True
|
logbook_parseable = True
|
||||||
print(" - Parsing logbook: " + year_settings[0] + "\n - Using parser: " + year_settings[1])
|
print(" - Parsing logbook: " + year_settings[0] + "\n - Using parser: " + year_settings[1])
|
||||||
|
|
||||||
|
if logbook_parseable:
|
||||||
|
parser = globals()[parsefunc]
|
||||||
|
parser(expedition.year, expedition, txt)
|
||||||
|
SetDatesFromLogbookEntries(expedition)
|
||||||
|
# and this has also stored all the objects in logentries[]
|
||||||
|
print " - Storing " , len(logentries), " log entries"
|
||||||
|
cache_filename = os.path.join(expowebbase, year_settings[0])+".cache"
|
||||||
|
with open(cache_filename, "wb") as f:
|
||||||
|
pickle.dump(logentries, f, 2)
|
||||||
|
logentries=[] # flush for next year
|
||||||
|
|
||||||
|
if logbook_cached:
|
||||||
|
i=0
|
||||||
|
for entrytuple in range(len(logentries)):
|
||||||
|
date, place, title, text, trippeople, expedition, logtime_underground, \
|
||||||
|
entry_type = logentries[i]
|
||||||
|
#print " - - obj ", i, date, title
|
||||||
|
EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_underground,\
|
||||||
|
entry_type)
|
||||||
|
i +=1
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
file_in = open(os.path.join(expowebbase, expedition.year, settings.DEFAULT_LOGBOOK_FILE))
|
file_in = open(os.path.join(expowebbase, expedition.year, settings.DEFAULT_LOGBOOK_FILE))
|
||||||
@@ -362,25 +380,6 @@ def LoadLogbookForExpedition(expedition):
|
|||||||
logbook_parseable = False
|
logbook_parseable = False
|
||||||
print("Couldn't open default logbook file and nothing in settings for expo " + expedition.year)
|
print("Couldn't open default logbook file and nothing in settings for expo " + expedition.year)
|
||||||
|
|
||||||
if logbook_parseable:
|
|
||||||
parser = globals()[parsefunc]
|
|
||||||
parser(expedition.year, expedition, txt)
|
|
||||||
SetDatesFromLogbookEntries(expedition)
|
|
||||||
# and this has also stored all the objects in logentries[]
|
|
||||||
print " - Storing " , len(logentries), " log entries"
|
|
||||||
with open(cache_filename, "wb") as f:
|
|
||||||
pickle.dump(logentries, f, 2)
|
|
||||||
logentries=[] # flush for next year
|
|
||||||
|
|
||||||
if logbook_cached:
|
|
||||||
i=0
|
|
||||||
for entrytuple in range(len(logentries)):
|
|
||||||
date, place, title, text, trippeople, expedition, logtime_underground, \
|
|
||||||
entry_type = logentries[i]
|
|
||||||
#print " - - obj ", i, date, title
|
|
||||||
EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_underground,\
|
|
||||||
entry_type)
|
|
||||||
i +=1
|
|
||||||
|
|
||||||
#return "TOLOAD: " + year + " " + str(expedition.personexpedition_set.all()[1].logbookentry_set.count()) + " " + str(models.PersonTrip.objects.filter(personexpedition__expedition=expedition).count())
|
#return "TOLOAD: " + year + " " + str(expedition.personexpedition_set.all()[1].logbookentry_set.count()) + " " + str(models.PersonTrip.objects.filter(personexpedition__expedition=expedition).count())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user