예제 #1
0
        a.BreedName = "%s / %s" % (asm.breed_name_for_id(
            a.BreedID), asm.breed_name_for_id(a.Breed2ID))
    comments = "Intake type: %s\nStatus: %s\nBreed: %s / %s\nAge: %s\nTemperament: %s" % \
        (d["Intake Type"], d["Status"], d["Primary Breed"], d["Mix Breed"], d["Age"], d["Temperament"])
    a.HiddenAnimalDetails = comments
    description = d["Description/Story"].replace("<p>",
                                                 "").replace("\n", "").replace(
                                                     "</p>", "\n")
    a.AnimalComments = description

    if d["Status"] == "Deceased":
        a.DeceasedDate = min(a.LastChangedDate, a.DateBroughtIn)
        a.PTSReasonID = 2
        a.Archived = 1
    elif d["Status"] == "Adopted":
        m = asm.Movement()
        m.AnimalID = a.ID
        m.OwnerID = uo.ID
        m.MovementType = 1
        m.MovementDate = a.DateBroughtIn
        m.Comments = description
        a.Archived = 1
        a.ActiveMovementDate = m.MovementDate
        a.ActiveMovementID = m.ID
        a.ActiveMovementType = 1
        a.LastChangedDate = m.MovementDate
        movements.append(m)
    elif d["Status"] == "Transferred Out":
        m = asm.Movement()
        m.AnimalID = a.ID
        m.OwnerID = uo.ID
예제 #2
0
        ownerdonations.append(od)
        nextownerdonationid += 1
        if nextownerdonationid == 7801: nextownerdonationid = 7900 # Avoid later added recs
        od.OwnerID = o.ID
        od.AnimalID = a.ID
        od.MovementID = 0
        od.Comments = row[ADOPT_PAYMENT_TYPE] + " " + row[ADOPT_PAYMENT__] + " " + row[ADOPT_EXP_DATE]
        od.Date = getdate(row[ADOPT_DATE_OF_ADOPTION])
        od.Donation = getcurrency(row[ADOPT_ADOPTION_FEE])
        od.DonationTypeID = 2 # Adoption Fee
        od.DonationPaymentID = getpaymentmethod(row[ADOPT_PAYMENT_TYPE])

    evtdate = getdate(row[ADOPT_DATE_OF_ADOPTION])

    if row[GUEST_GUEST_STATUS] == "ADOPTED":
        m = asm.Movement(nextmovementid)
        nextmovementid += 1
        if nextmovementid == 7771: nextmovementid = 8000 # Avoid later added recs
        m.AnimalID = a.ID
        m.OwnerID = o is None and 100 or o.ID
        m.MovementType = 1
        m.MovementDate = evtdate
        m.Comments = row[ADOPT_COMMENT]
        m.ReturnDate = getdate(row[ADOPT_DATE_RETURNED])
        a.Archived = 1
        a.ActiveMovementDate = evtdate
        a.ActiveMovementID = m.ID
        a.ActiveMovementType = 1
        movements.append(m)
        if od is not None:
            od.MovementID = m.ID
예제 #3
0
        a.ShelterLocation = 1
        a.BreedID = getbreed(row[DESCRIPTION])
        a.Breed2ID = getbreed(row[DESCRIPTION])
        a.BreedName = getbreedname(a.BreedID)
        if row[DATEOFBIRTH].strip() != "":
            a.DateOfBirth = getdate(row[DATEOFBIRTH])
        if row[DATEIN].strip() != "": a.DateBroughtIn = getdate(row[DATEIN])
        if row[DIED].strip() != "": a.DeceasedDate = getdate(row[DIED])
        print a
    else:
        aid = codes[code]

    # Movements

    if row[ADOPTED].strip() != "":
        am = asm.Movement()
        am.OwnerID = o.ID
        am.AnimalID = aid
        am.MovementDate = getdate(row[ADOPTED])
        am.MovementType = 1
        if row[RETURNEDTO].strip() != "":
            am.ReturnDate = getdate(row[RETURNEDTO])
        print am

    elif row[TRANSFERRED].strip() != "":
        am = asm.Movement()
        am.OwnerID = o.ID
        am.AnimalID = aid
        am.MovementDate = getdate(row[TRANSFERRED])
        am.MovementType = 3
        if row[RETURNEDTO].strip() != "":
예제 #4
0
def process_impound(d, dt):
    a = asm.Animal()
    animals.append(a)
    a.EntryReasonID = 7  # Stray
    if d["Species"].lower() == "cat":
        a.AnimalTypeID = 12  # Stray Cat
    elif d["Species"].lower() == "dog":
        a.AnimalTypeID = 10  # Stray Dog
    else:
        a.AnimalTypeID = 40  # Misc
    a.SpeciesID = asm.species_id_for_name(d["Species"])
    a.AnimalName = d["Animal's Name"].replace("\n", " ")
    if a.AnimalName == "?" or a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    releasedate = getdate(d["Date of Release"])
    intakedate = getdate(d["Date of P/U"])
    if intakedate is None and releasedate is not None: intakedate = releasedate
    if intakedate is None: intakedate = dt
    a.DateBroughtIn = intakedate
    a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, 365)
    a.CreatedDate = a.DateBroughtIn
    a.LastChangedDate = a.DateBroughtIn
    a.generateCode()
    a.Sex = asm.getsex_mf(d["Sex-Altered?"])
    a.Size = 2
    a.Neutered = asm.iif(
        d["Sex-Altered?"].lower() == "mn" or d["Sex-Altered?"].lower() == "fs",
        1, 0)
    a.IdentichipNumber = d["Microchip"]
    if a.IdentichipNumber != "no chip found" and a.IdentichipNumber != "Unable to scan" and a.IdentichipNumber != "no" and a.IdentichipNumber != "":
        a.Identichipped = 1
    asm.breed_ids(a, d["Breed"], default=442)
    if d["Breed"].lower().find("mix") != -1 or d["Breed"].find("X") != -1:
        a.CrossBreed = 1
        a.Breed2ID = 442
    a.HiddenDetails = "Breed: %s\nColor: %s\nCollar: %s\nTags: %s\nMicrochip: %s\n" % (
        d["Breed"], d["Color"], d["Collar"], d["Tags"], d["Microchip"])
    a.Comments = d["Comments"]
    # Now create the owner
    if d["Owner's Name"] != "n/a" and d["Owner's Name"] != "" and d[
            "Owner's Name"] != "?" and d[
                "Owner's Name"] != "Went to Rescue" and d[
                    "Owner's Name"] != "unknown" and d["Address"] != "" and d[
                        "Address"] != "n/a":
        o = asm.Owner()
        owners.append(o)
        name = d["Owner's Name"]
        lastname = name
        firstname = ""
        if name.find(" ") != -1:
            firstname, lastname = name.split(" ", 1)
        ppo[name] = o
        o.OwnerForeNames = firstname
        o.OwnerSurname = lastname
        o.OwnerName = "%s, %s" % (lastname, firstname)
        o.OwnerAddress = d["Address"]
        o.OwnerTown = "Burnsville"
        o.OwnerCounty = "MN"
        o.HomeTelephone = d["Phone #"]
        # Reclaim if there's a date
        if releasedate is not None:
            m = asm.Movement()
            m.AnimalID = a.ID
            m.OwnerID = o.ID
            m.MovementType = 5
            m.MovementDate = releasedate
            a.Archived = 1
            a.ActiveMovementID = m.ID
            a.ActiveMovementType = 5
            a.LastChangedDate = m.MovementDate
            movements.append(m)
    # Was the animal euthanised?
    if "Euthanized" in d and d["Euthanized"] == "1":
        a.DeceasedDate = releasedate or intakedate
        a.PutToSleep = 1
        a.PTSReasonID = 4
        a.PTSReason = d["If Euthanized, Why?"]
        a.Archived = 1
    # Is this animal still on shelter? If so, we need to get it off with a fake reclaim
    if a.Archived == 0:
        m = asm.Movement()
        m.AnimalID = a.ID
        m.OwnerID = uo.ID
        m.MovementType = 5
        m.MovementDate = releasedate or intakedate
        a.Archived = 1
        a.ActiveMovementID = m.ID
        a.ActiveMovementType = 5
        a.LastChangedDate = m.MovementDate
        movements.append(m)
예제 #5
0
                      yearfromfilename(file))
        # Stick bits we can't convert 100% in the animal's hidden comments
        a.HiddenAnimalDetails = "Previous ID:%s\nDescription: %s\nRescued From: %s\nLast Flea: %s\nLast Worm: %s\nIndoor/Outdoor: %s\nShots: %s\nTested: %s" % (
            row[ID], row[DESCRIPTION], row[RESCUEDFROM], row[LASTFLEA],
            row[LASTWORM], row[INDOOR], row[SHOTS], row[TESTED])
        a.AnimalComments = row[COMMENTS]
        adoptiondate = getmydate(row[ADOPTIONDATE], True,
                                 yearfromfilename(file))

        # Do we have a foster name? If so, Find/Create the fosterer
        if row[FOSTERHOME].strip() != "":
            fosterer = findowner(row[FOSTERHOME])
            fosterer.IsFosterer = 1
            # Create a foster movement, with the animal returned on
            # the adoption date
            fm = asm.Movement()
            fm.OwnerID = fosterer.ID
            fm.AnimalID = a.ID
            fm.MovementDate = a.DateBroughtIn
            fm.MovementType = 2
            fm.ReturnDate = adoptiondate
            fm.ReturnedReasonID = 12
            movements.append(fm)

        # Create the adopter
        adopter = findowner(row[FORENAMES] + " " + row[SURNAME])
        adopter.OwnerSurname = row[SURNAME]
        adopter.OwnerForeNames = row[FORENAMES]
        adopter.OwnerAddress = row[ADDRESS1]
        if row[ADDRESS2].strip() != "":
            adopter.OwnerAddress += "\n" + row[ADDRESS2]