# Turn memos into history logs if MEMO_FILENAME != "" and asm.file_exists(MEMO_FILENAME): idfield = "AnimalID" for d in asm.csv_to_list(MEMO_FILENAME): if "textbox20" not in d: continue # Can't do anything without our field if d["textbox20"] == "textbox20": continue # Ignore repeated headers if not d.has_key(idfield): idfield = "Name" if ppa.has_key(d[idfield]): a = ppa[d[idfield]] l = asm.Log() logs.append(l) l.LogTypeID = 3 # History l.LinkID = a.ID l.LinkType = 0 l.Date = asm.getdate_mmddyyyy(d["textbox20"]) if l.Date is None: l.Date = asm.now() l.Comments = d["Textbox131"] if CASES_FILENAME != "" and asm.file_exists(CASES_FILENAME): ctmap = { "Neglect/ Cruelty": 7, "Bite": 5, "Nuisance": 8, "Stray": 3, "wildlife": 3, "Assist Police/Fire": 3, "Feral Cat": 3, "Injured": 10, "TNR": 10
uo.OwnerName = uo.OwnerSurname owners.append(uo) # petpal files are newest first order for d in reversed(data): a = asm.Animal() animals.append(a) a.AnimalTypeID = asm.iif(d["Pet Type"] == "Cat", 11, 2) if a.AnimalTypeID == 11 and d["Intake Type"] == "Stray": a.AnimalTypeID = 12 a.SpeciesID = asm.species_id_for_name(d["Pet Type"]) a.AnimalName = d["Pet Name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" if d["DOB"].strip() == "": a.DateOfBirth = asm.getdate_mmddyyyy(d["Intake Date"]) a.EstimatedDOB = 1 else: a.DateOfBirth = asm.getdate_mmddyyyy(d["DOB"]) if a.DateOfBirth is None: a.DateOfBirth = asm.today() a.EstimatedDOB = 1 a.DateBroughtIn = asm.getdate_mmddyyyy(d["Intake Date"]) if a.DateBroughtIn is None: a.DateBroughtIn = asm.today() a.CreatedDate = asm.getdate_mmddyyyy(d["Added On"]) a.CreatedBy = "%s/%s" % (d["Added By"], "conversion") a.LastChangedDate = asm.getdate_mmddyyyy(d["Updated On"]) a.LastChangedBy = d["Last Updated By"] if a.CreatedDate is None: a.CreatedDate = asm.today() if a.LastChangedDate is None: a.LastChangedDate = asm.today()
def getdate(s): if DATE_FORMAT == "DMY": return asm.getdate_ddmmyyyy(s) else: return asm.getdate_mmddyyyy(s)
def getdate(s): return asm.getdate_mmddyyyy(s)
# Turn memos into history logs if MEMO_FILENAME != "" and asm.file_exists(MEMO_FILENAME): idfield = "AnimalID" datefield = "textbox20" memofield = "Textbox131" for d in asm.csv_to_list(MEMO_FILENAME): if datefield not in d: continue # Can't do anything without our field if d[datefield] == datefield: continue # Ignore repeated headers if d[idfield] in ppa: a = ppa[d[idfield]] l = asm.Log() logs.append(l) l.LogTypeID = 3 # History l.LinkID = a.ID l.LinkType = 0 l.Date = asm.getdate_mmddyyyy(d["textbox20"]) if l.Date is None: l.Date = asm.now() l.Comments = d["Textbox131"] # Turn memos into history logs if PMEMO_FILENAME != "" and asm.file_exists(PMEMO_FILENAME): idfield = "textbox49" datefield = "textbox58" memofield = "Memo" for d in asm.csv_to_list(PMEMO_FILENAME): if datefield not in d: continue # Can't do anything without our field if d[datefield] == datefield: continue # Ignore repeated headers if d[idfield] in ppo: o = ppo[d[idfield]] l = asm.Log()
def get_dispatch_date(s): """ Parses one of their dispatch dates """ if s.strip() == "": return None return asm.getdate_mmddyyyy(s[:s.find(" ")])
broughtin = getdate(d["Created"]) a.DateBroughtIn = broughtin dob = broughtin a.EstimatedDOB = 1 if "General Age" in d: if d["General Age"].find("Baby") != -1: dob = asm.subtract_days(asm.today(), 91) elif d["General Age"].find("Young") != -1: dob = asm.subtract_days(asm.today(), 182) elif d["General Age"].find("Adult") != -1: dob = asm.subtract_days(asm.today(), 730) elif d["General Age"].find("Senior") != -1: dob = asm.subtract_days(asm.today(), 2555) if "Birthdate" in d and d["Birthdate"] != "": dob = asm.getdate_mmddyyyy(d["Birthdate"]) a.EstimatedDOB = 0 a.DateOfBirth = dob a.Sex = 1 if d["Sex"].startswith("F"): a.Sex = 0 breed1 = "" breed2 = "" mixed = "No" if "Primary Breed" in d: breed1 = d["Primary Breed"] breed2 = d["Secondary Breed"] mixed = d["Mixed"] elif "Breed" in d: # Breed is in form breed1 / breed2 / mixed, sections only present if set