mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-30 05:41:56 +00:00
[svn r8326] fix import naming mistake
This commit is contained in:
parent
a5b2db7206
commit
9cabd7203e
@ -4,7 +4,7 @@ import csv
|
|||||||
import settings
|
import settings
|
||||||
from expo.models import QM, LogbookEntry, Cave
|
from expo.models import QM, LogbookEntry, Cave
|
||||||
from datetime import *
|
from datetime import *
|
||||||
from helpers import save_carefully
|
from save_carefully import save_carefully
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def deleteQMs():
|
def deleteQMs():
|
||||||
|
@ -9,7 +9,7 @@ import time
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from troggle.helpers import save_carefully
|
from save_carefully import save_carefully
|
||||||
|
|
||||||
##format of CAVETAB2.CSV is
|
##format of CAVETAB2.CSV is
|
||||||
KatasterNumber = 0
|
KatasterNumber = 0
|
||||||
|
@ -13,7 +13,7 @@ import re
|
|||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from troggle.helpers import save_carefully
|
from save_carefully import save_carefully
|
||||||
|
|
||||||
#
|
#
|
||||||
# When we edit logbook entries, allow a "?" after any piece of data to say we've frigged it and
|
# When we edit logbook entries, allow a "?" after any piece of data to say we've frigged it and
|
||||||
|
@ -7,7 +7,7 @@ import re
|
|||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from helpers import save_carefully
|
from save_carefully import save_carefully
|
||||||
|
|
||||||
# Julian: the below code was causing errors and it seems like a duplication of the above. Hope I haven't broken anything by commenting it. -Aaron
|
# Julian: the below code was causing errors and it seems like a duplication of the above. Hope I haven't broken anything by commenting it. -Aaron
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
def save(objectType, lookupAttribs={}, nonLookupAttribs={}):
|
from settings import LOGFILE
|
||||||
|
|
||||||
|
def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}):
|
||||||
|
"""Looks up instance using lookupAttribs and carries out the following:
|
||||||
|
-if instance does not exist in DB: add instance to DB, return (new instance, True)
|
||||||
|
-if instance exists in DB and was modified using Troggle: do nothing, return (existing instance, False)
|
||||||
|
-if instance exists in DB and was not modified using Troggle: overwrite instance, return (instance, False)
|
||||||
|
|
||||||
|
The checking is accomplished using Django's get_or_create and the new_since_parsing boolean field
|
||||||
|
defined in expo.models.TroggleModel.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
instance, created=objectType.objects.get_or_create(defaults=nonLookupAttribs, **lookupAttribs)
|
instance, created=objectType.objects.get_or_create(defaults=nonLookupAttribs, **lookupAttribs)
|
||||||
|
|
||||||
@ -7,4 +18,14 @@ def save(objectType, lookupAttribs={}, nonLookupAttribs={}):
|
|||||||
setattr(instance, k, v)
|
setattr(instance, k, v)
|
||||||
instance.save()
|
instance.save()
|
||||||
|
|
||||||
return instance
|
if LOGFILE:
|
||||||
|
if created:
|
||||||
|
LOGFILE.write(unicode(instance)+u' was just added to the database for the first time. \n')
|
||||||
|
|
||||||
|
if not created and instance.new_since_parsing:
|
||||||
|
LOGFILE.write(unicode(instance)+" has been modified using Troggle, so the current script left it as is. \n")
|
||||||
|
|
||||||
|
if not created and not instance.new_since_parsing:
|
||||||
|
LOGFILE.write(unicode(instance)+" existed in the database unchanged since last parse. It was overwritten by the current script. \n")
|
||||||
|
LOGFILE.flush()
|
||||||
|
return (instance, created)
|
Loading…
Reference in New Issue
Block a user