a.ShortCode = code a.NeuteredDate = asm.getdate_mmddyy(row["SpayNeuterPerformedDate"]) if a.NeuteredDate is not None: a.Neutered = 1 # 1 = neutered, 2 = spayed, 3 = entire, 5 = unknown if row["sysAlteredChoicesID"] == "1" or row["sysAlteredChoicesID"] == "2": a.Neutered = 1 a.Markings = row["DistinguishingMarks"] a.HealthProblems = row["Condition"] a.AnimalComments = row["Description"] a.Weight = asm.atoi(row["Weight"]) a.IsNotAvailableForAdoption = 0 location = asm.find_value(cshelterareas, "sysShelterAreasID", row["sysShelterAreasID"], "ShelterArea") pen = asm.find_value(cpens, "sysPensID", row["sysPensID"], "Pen") a.ShelterLocation = asm.location_from_db(location, 1) a.ShelterLocationUnit = pen a.Sex = asm.getsex_mf( asm.find_value(cgenders, "sysGenderChoicesID", row["sysGenderChoicesID"], "GenderChoice")) a.Size = 2 color1 = asm.find_value(ccolors, "sysCoatColorsID", row["ColorPrimaryID"], "Description") color2 = asm.find_value(ccolors, "sysCoatColorsID", row["ColorSecondaryID"], "Description") a.BaseColourID = asm.colour_id_for_names(asm.fw(color1), asm.fw(color2)) #a.IdentichipNumber = row["MICROCHIP"] breed1 = asm.find_value(cbreeds, "sysBreedsID", row["sysBreedPrimaryID"], "Breed") breed2 = asm.find_value(cbreeds, "sysBreedsID", row["sysBreedSecondaryID"], "Breed")
comments = "Breed: " + d["Breed"] + "/" + d["Cross_Breed"] comments += "\nSpecies: " + d["Species"] comments += "\nMicrochip Type: " + d["Microchip_Type"] comments += "\nSize: " + d["Size"] comments += "\nCondition: " + d["Animal_Condition"] a.HiddenAnimalDetails = comments entrycomments = "Pound Reason: " + d["Pound_Reason"] entrycomments += "\nWhere Found: " + d["Where_found"] entrycomments += "\nStreet Found: " + d["Street_Found_In"] a.ReasonForEntry = entrycomments a.EntryReasonID = 17 # Surrender #if d["InShelterSearchFlag"] == "N": # a.Archived = 1 if d["Animal_Location"] != "": a.ShelterLocation = asm.location_from_db(d["Location"]) if d["Animal_Unit"] != "": a.ShelterLocationUnit = d["Unit"] # Animal log, recording medical history and linking adoptions/surrenderers/etc for d in asm.csv_to_list(LOG_FILENAME, remove_non_ascii=True): if d["Animal_Identifier"] not in ppa: continue a = ppa[d["Animal_Identifier"]] o = uo if d["People_ctr"] != "": o = ppo[d["People_ctr"]] ed = getdate(d["Entry_date"]) if not ed: continue if d["Weight"] != "0" and d["Weight"] != "": try: a.Weight = float(d["Weight"])
a.AnimalName = "(unknown)" a.DateBroughtIn = getdate(d["Date brought in"]) if a.DateBroughtIn is None: a.DateBroughtIn = asm.today() if "Date Of Birth" in d and d["Date of Birth"].strip() != "": a.DateOfBirth = getdate(d["Date of Birth"]) else: a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, 365) a.EstimatedDOB = d["Estimate"] == "Yes" and 1 or 0 a.CreatedDate = a.DateBroughtIn a.LastChangedDate = a.DateBroughtIn a.generateCode() if d["Old number (notes field)"] != "": a.ShortCode = d["Old number (notes field)"] a.ReasonForEntry = d["Reason for Entry"] a.ShelterLocation = asm.location_from_db(d["Internal Location"]) a.Sex = asm.getsex_mf(d["Sex"]) a.BreedID = "COALESCE((SELECT ID FROM breed WHERE BreedName LIKE '%s' LIMIT 1), 1)" % d[ "Breed 1"] if d["Breed 2"].strip() == "" or d["Breed 2"] == "NULL": a.Breed2ID = a.BreedID a.BreedName = asm.breed_name_for_id(a.BreedID) a.CrossBreed = 0 else: a.Breed2ID = "COALESCE((SELECT ID FROM breed WHERE BreedName LIKE '%s' LIMIT 1), 1)" % d[ "Breed 2"] a.BreedName = asm.breed_name_for_id( a.BreedID) + " / " + asm.breed_name_for_id(a.Breed2ID) a.CrossBreed = 1 a.BaseColourID = asm.colour_id_for_name(d["Colour"]) a.Markings = d["Markings"]
a.ShelterCode = code a.ShortCode = code a.NeuteredDate = asm.getdate_mmddyy(row["SpayNeuterPerformedDate"]) if a.NeuteredDate is not None: a.Neutered = 1 # 1 = neutered, 2 = spayed, 3 = entire, 5 = unknown if row["sysAlteredChoicesID"] == "1" or row["sysAlteredChoicesID"] == "2": a.Neutered = 1 a.Markings = row["DistinguishingMarks"] a.HealthProblems = row["Condition"] a.AnimalComments = row["Description"] a.Weight = asm.atoi(row["Weight"]) a.IsNotAvailableForAdoption = 0 location = asm.find_value(cshelterareas, "sysShelterAreasID", row["sysShelterAreasID"], "ShelterArea") pen = asm.find_value(cpens, "sysPensID", row["sysPensID"], "Pen") a.ShelterLocation = asm.location_from_db(location, 1) a.ShelterLocationUnit = pen a.Sex = asm.getsex_mf(asm.find_value(cgenders, "sysGenderChoicesID", row["sysGenderChoicesID"], "GenderChoice")) a.Size = 2 color1 = asm.find_value(ccolors, "sysCoatColorsID", row["ColorPrimaryID"], "Description") color2 = asm.find_value(ccolors, "sysCoatColorsID", row["ColorSecondaryID"], "Description") a.BaseColourID = asm.colour_id_for_names(asm.fw(color1), asm.fw(color2)) #a.IdentichipNumber = row["MICROCHIP"] breed1 = asm.find_value(cbreeds, "sysBreedsID", row["sysBreedPrimaryID"], "Breed") breed2 = asm.find_value(cbreeds, "sysBreedsID", row["sysBreedSecondaryID"], "Breed") a.BreedID = asm.breed_id_for_name(breed1) a.Breed2ID = asm.breed_id_for_name(breed2) # Not sure if this was customer specific with the (Mix) (Purebred) - # needs checking on future conversions if breed2 == "(Mix)": a.Breed2ID = 442