animalcontrol.append(ac) if c["COMPLANANT"] != "Unspecified" and ppo.has_key(c["COMPLANANT"]): ac.CallerID = ppo[c["COMPLANANT"]].ID if c["OWNER"] != "Unspecified" and ppo.has_key(c["OWNER"]): ac.OwnerID = ppo[c["OWNER"]].ID ac.CallDateTime = c["OPENDT"] if ac.CallDateTime is None: ac.CallDateTime = c["LUPTDT"] if ac.CallDateTime is None: ac.CallDateTime = asm.now() ac.IncidentDateTime = ac.CallDateTime ac.DispatchDateTime = ac.CallDateTime ac.CompletedDate = c["CLOSEDT"] ac.IncidentTypeID = 3 if typemap.has_key(c["CASETYPE"]): ac.IncidentTypeID = typemap[c["CASETYPE"]] ac.DispatchAddress = c["COMPADDR"] comments = asm.nulltostr(c["CASEDESC"]) comments += "\nBeat: %s" % c["BEAT"] comments += "\nOfficer: %s" % c["OFFICER"] comments += "\nType: %s" % c["CASETYPE"] comments += "\nValid: %s" % c["COMPVALID"] comments += "\nCondition: %s" % c["ANMLCOND"] if type(comments) == unicode: comments = comments.encode("ascii", "xmlcharrefreplace") ac.CallNotes = comments if c["ANIMALNO"] != "Unspecified" and ppa.has_key(c["ANIMALNO"]): animalcontrolanimal.append("INSERT INTO animalcontrolanimal (AnimalID, AnimalControlID) VALUES (%d, %d);" % (ppa[c["ANIMALNO"]].ID, ac.ID)) except: pass # we had a corrupted file from a customer, that's why this is here for c in DBF("%s/BITES.DBF" % PATH, encoding="latin1"): ac = asm.AnimalControl() animalcontrol.append(ac)
for p in DBF("%s/NAMES.DBF" % PATH): o = asm.Owner() owners.append(o) ppo[p["ID"]] = o o.OwnerForeNames = p["F_NAME"] o.OwnerSurname = p["L_NAME"] o.OwnerAddress = "%s %s\n%s" % (p["ADR_ST_NUM"], p["ADR_ST_NAM"], p["ADR_LINE2"]) o.OwnerTown = p["CITY"] o.OwnerCounty = p["STATE"] o.OwnerPostcode = p["ZIP"] o.HomeTelephone = p["H_PHONE"] o.WorkTelephone = p["W_PHONE"] comments = "ID: %s" % p["ID"] comments += "\n%s" % asm.nulltostr(p["NAMES_TXT"]) o.Comments = comments for d in DBF("%s/ANIMALS.DBF" % PATH): a = asm.Animal() animals.append(a) ppa[d["ID_NUM"]] = a a.AnimalName = d["NAME"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" if d["SPECIES"] == "C": # Canine a.SpeciesID = 1 if d["SURR_CODE"] == "STR": a.AnimalTypeID = 10 a.EntryReasonID = 11
def note_fix(s): return asm.nulltostr(s).encode("ascii", "xmlcharrefreplace")
o.ExcludeFromBulkEmail = d.contactReceiveNoMail o.CreatedDate = d.dateAdded or asm.today() o.CreatedBy = d.addedBy or "conversion" o.LastChangedBy = d.modifiedBy or "conversion" o.LastChangedDate = d.dateModifed or o.CreatedDate # Now dogs for d in db.select("Dogs").list() + db.select("Dogs_old").list(): # Each row contains an animal a = asm.Animal() animals.append(a) ppa[d.dogID] = a has_intake = True a.SpeciesID = 1 a.AnimalTypeID = 2 a.BaseColourID = asm.colour_id_for_name(asm.nulltostr(d.dogColor), firstWordOnly=True) a.BreedID = 101 # Greyhound a.Breed2ID = a.BreedID a.BreedName = "Greyhound" a.AnimalName = note_fix(d.dogCallName) if a.AnimalName.strip() == "": a.AnimalName = note_fix(d.dogRegisteredName) if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.DateBroughtIn = d.dogIntakeDate or d.dateAdded a.DateOfBirth = d.dogDateBorn or a.DateBroughtIn a.CreatedDate = d.dateAdded or a.DateBroughtIn a.CreatedBy = d.addedBy or "conversion" a.LastChangedBy = d.modifiedBy or "conversion" a.LastChangedDate = d.dateModified or a.CreatedDate a.generateCode() if d.dogSerialNum and asm.nulltostr(d.dogSerialNum) != "":
print "DELETE FROM adoption WHERE ID >= 100;" for p in DBF("%s/NAMES.DBF" % PATH): o = asm.Owner() owners.append(o) ppo[p["ID"]] = o o.OwnerForeNames = p["F_NAME"] o.OwnerSurname = p["L_NAME"] o.OwnerAddress = "%s %s\n%s" % (p["ADR_ST_NUM"], p["ADR_ST_NAM"], p["ADR_LINE2"]) o.OwnerTown = p["CITY"] o.OwnerCounty = p["STATE"] o.OwnerPostcode = p["ZIP"] o.HomeTelephone = p["H_PHONE"] o.WorkTelephone = p["W_PHONE"] comments = "ID: %s" % p["ID"] comments += "\n%s" % asm.nulltostr(p["NAMES_TXT"]) o.Comments = comments for d in DBF("%s/ANIMALS.DBF" % PATH): a = asm.Animal() animals.append(a) ppa[d["ID_NUM"]] = a a.AnimalName = d["NAME"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" if d["SPECIES"] == "C": # Canine a.SpeciesID = 1 if d["SURR_CODE"] == "STR": a.AnimalTypeID = 10 a.EntryReasonID = 11
print "DELETE FROM internallocation;" print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerdonation WHERE ID >= 100;" print "DELETE FROM adoption WHERE ID >= 100;" # Deal with people first for d in db.select("members").list(): # Each row contains a person o = asm.Owner() owners.append(o) ppo[d.id] = o o.OwnerForeNames = d.first_name o.OwnerSurname = d.last_name o.OwnerName = o.OwnerForeNames + " " + o.OwnerSurname o.OwnerAddress = asm.nulltostr(d.address_1) + " " + asm.nulltostr( d.address_2) o.OwnerTown = asm.nulltostr(d.address_3) o.OwnerCounty = asm.nulltostr(d.address_4) o.OwnerPostcode = asm.nulltostr(d.post_code) o.EmailAddress = asm.nulltostr(d.email) o.HomeTelephone = asm.nulltostr(d.phone) o.IsGiftAid = d.gift_aid o.Comments = note_fix(d.notes) # Secondary members - merge name and telephone number for d in db.select("secondary_members").list(): if not ppo.has_key(d.member_id): continue o = ppo[d.member_id] if d.first_name is not None and d.first_name != "": o.OwnerForeNames += " & " + d.first_name
a.Sex = asm.getsex_mf(row.Sex) a.generateCode(gettypeletter(a.AnimalTypeID)) a.ShortCode = row.AnimalUid a.AnimalName = row.Name if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.RabiesTag = row.RabiesNum a.ShelterLocationUnit = row.CageLocation a.Markings = row.Marking a.GoodWithCats = ynu(row.GoodWithCats) a.GoodWithDogs = ynu(row.GoodWithDogs) a.GoodWithChildren = ynu(row.GoodWithChildren) a.HouseTrained = ynu(row.HouseBroken) a.AnimalComments = row.Comments a.HiddenAnimalDetails = "Original breed: %s / %s, color: %s" % (row.Breed1, row.Breed2, row.ColorName) a.IdentichipNumber = asm.nulltostr(row.MicrochipID) if a.IdentichipNumber != "": a.Identichipped = 1 a.TattooNumber = asm.nulltostr(row.tattoo) if a.TattooNumber != "": a.Tattoo = 1 if row.Size == "X": a.Size = 0 if row.Size == "L": a.Size = 1 if row.Size == "M": a.Size = 2 if row.Size == "S": a.Size = 3 if row.AlteredAtIntake == "Y": a.Neutered = 1 a.NeuteredDate = row.AlteredDate if a.NeuteredDate is not None: a.Neutered = 1 if row.Declawed == "Y": a.Declawed = 1 if str(row.IntakeCustUid) in ppo: a.OriginalOwnerID = ppo[str(row.IntakeCustUid)].ID