diff --git a/core/models_caves.py b/core/models_caves.py index 8df2639..e20b17f 100644 --- a/core/models_caves.py +++ b/core/models_caves.py @@ -125,7 +125,7 @@ class Cave(TroggleModel): return urljoin(settings.URL_ROOT, reverse('cave',kwargs={'cave_id':href,})) def __str__(self, sep = ": "): - return "[Cave:" + str(self.slug()) + "]" + return str(self.slug()) def get_QMs(self): return QM.objects.filter(found_by__cave_slug=self.caveslug_set.all()) diff --git a/databaseReset.py b/databaseReset.py index d1d6733..9551298 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -278,6 +278,8 @@ def usage(): profile - print the profile from previous runs. Import nothing. 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) people - read in the people from folk.csv (must run after 'caves') logbooks - read in the logbooks @@ -312,6 +314,8 @@ if __name__ == "__main__": if len(sys.argv)==1: usage() exit() + elif "init" in sys.argv: + jq.enq("reinit",reinit_db) elif "test" in sys.argv: jq.enq("caves",import_caves) jq.enq("people",import_people) diff --git a/parsers/logbooks.py b/parsers/logbooks.py index a724394..a492135 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -148,7 +148,7 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_ for tripperson, time_underground in trippersons: lookupAttribs={'personexpedition':tripperson, 'logbook_entry':lbo} 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): """ Interprets dates in the expo logbooks and returns a correct datetime.date object """ @@ -394,7 +394,7 @@ def SetDatesFromLogbookEntries(expedition): lprevpersontrip.save() persontrip.persontrip_next = None lprevpersontrip = persontrip - persontrip.save() + persontrip.save() # also saved in EnterLogIntoDbase. MERGE these to speed up import. def LoadLogbookForExpedition(expedition,expect): diff --git a/utils.py b/utils.py index 0c56b73..920fcdf 100644 --- a/utils.py +++ b/utils.py @@ -62,6 +62,10 @@ def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}): print(" !! - -- instance.save()") print(" !! - lookupAttribs:{}\n !! - nonLookupAttribs:{}".format(lookupAttribs,nonLookupAttribs)) raise + try: + msg = str(instance) + except: + msg = "FAULT getting __str__ for instance with lookupattribs: {}:".format(lookupAttribs) if created: logging.info(str(instance) + ' was just added to the database for the first time. \n')