# Create an unknown owner uo = asm.Owner() owners.append(uo) uo.OwnerSurname = "Unknown Owner" uo.OwnerName = uo.OwnerSurname pf = "" if PETFINDER_ID != "": asm.setid("media", START_ID) asm.setid("dbfs", START_ID) print "DELETE FROM media WHERE ID >= %s;" % START_ID print "DELETE FROM dbfs WHERE ID >= %s;" % START_ID pf = asm.petfinder_get_adoptable(PETFINDER_ID) # Deal with people first (if set) if PERSON_FILENAME != "" and asm.file_exists(PERSON_FILENAME): for d in asm.csv_to_list(PERSON_FILENAME): # Ignore repeated headers if d["Person ID"] == "Person ID": continue # Each row contains a person o = asm.Owner() owners.append(o) ppo[d["Person ID"]] = o o.OwnerForeNames = d["Name First"] o.OwnerSurname = d["Name Last"] o.OwnerName = o.OwnerForeNames + " " + o.OwnerSurname o.OwnerAddress = d["Street Address"] o.OwnerTown = d["City"] o.OwnerCounty = d["Province"] o.OwnerPostcode = d["Postal Code"] o.EmailAddress = d["Email"]
a.CreatedDate = m.MovementDate elif o is not None: # assume the person is the fosterer m = asm.Movement() movements.append(m) o.IsFosterer = 1 m.AnimalID = a.ID m.OwnerID = o.ID m.MovementType = 2 m.MovementDate = a.DateBroughtIn a.ActiveMovementID = m.ID a.ActiveMovementDate = m.MovementDate a.ActiveMovementType = 2 a.CreatedDate = m.MovementDate if asm.file_exists("%s/vet_visits.csv" % PATH): for d in asm.csv_to_list("%s/vet_visits.csv" % PATH): if d["animal_id"] == "animal_id": continue if d["animal_id"] not in ppa: continue a = ppa[d["animal_id"]] meddate = getdate(d["visit_date"]) m = asm.animal_regimen_single(a.ID, meddate, d["treatment"], "Vet Visit", d["reason"], cost=asm.cfloat(d["cost"]) * 100) animalmedicals.append(m) if FETCH_MEDIA and asm.file_exists("%s/documents.csv" % PATH): for d in asm.csv_to_list("%s/documents.csv" % PATH):
a.EntryReasonID = 17 # Surrender a.OriginalOwnerID = linkperson a.BroughtInByOwnerID = linkperson a.ReasonForEntry = "%s / %s" % (intaketype, subtype) # Last customer broke both categories and manually entered everything in # ASM's lookup data before conversion. # The lines below will look up the entry reason and animal type in the target # db from intake/subtype if the option is on. if USE_SMDB_ENTRY_TYPE: a.EntryReasonID = asm.entryreason_from_db(intaketype) a.AnimalTypeID = asm.animaltype_from_db(subtype) # This file was sent by one customer, it looks like the events - intake file, but contains # animals that only came in for some kind of service (typically feral spay/neuter), we # use it to flag animals as non-shelter if asm.file_exists("%s/nonshelter.csv" % PATH): for d in asm.csv_to_list("%s/nonshelter.csv" % PATH): if d["Animal ID"] == "Animal ID": continue if d["Animal ID"] not in ppa: continue a = ppa[d["Animal ID"]] a.NonShelterAnimal = 1 a.Archived = 1 linkperson = 0 if "Intake From Name" in d and d["Intake From Name"] != "" and d[ "Intake From Name"] in ppo: linkperson = ppo[d["Intake From Name"]].ID a.OriginalOwnerID = linkperson for d in asm.csv_to_list("%s/outcomes.csv" % PATH): if d["Animal ID"] == "Animal ID": continue # skip repeated headers o = None