Example #1
0
 def test_get_fields(self):
     animal.get_latest_movement(base.get_dbo(), self.nid)
     assert True == animal.get_is_on_shelter(base.get_dbo(), self.nid)
     animal.get_comments(base.get_dbo(), self.nid)
     animal.get_date_of_birth(base.get_dbo(), self.nid)
     animal.get_days_on_shelter(base.get_dbo(), self.nid)
     animal.get_daily_boarding_cost(base.get_dbo(), self.nid)
     animal.get_deceased_date(base.get_dbo(), self.nid)
     animal.get_date_brought_in(base.get_dbo(), self.nid)
     animal.get_display_location(base.get_dbo(), self.nid)
     animal.get_display_location_noq(base.get_dbo(), self.nid)
     animal.get_code(base.get_dbo(), self.nid)
     animal.get_short_code(base.get_dbo(), self.nid)
     animal.get_shelter_code(base.get_dbo(), self.nid)
     animal.get_animal_namecode(base.get_dbo(), self.nid)
     assert animal.get_number_animals_on_shelter_now(base.get_dbo()) > 0
     assert True == animal.get_has_animals(base.get_dbo())
     assert True == animal.get_has_animal_on_shelter(base.get_dbo())
     animal.get_preferred_web_media_name(base.get_dbo(), self.nid)
Example #2
0
 def test_get_fields(self):
     assert True == animal.get_is_on_shelter(base.get_dbo(), self.nid)
     animal.get_comments(base.get_dbo(), self.nid)
     animal.get_date_of_birth(base.get_dbo(), self.nid)
     animal.get_days_on_shelter(base.get_dbo(), self.nid)
     animal.get_daily_boarding_cost(base.get_dbo(), self.nid)
     animal.get_deceased_date(base.get_dbo(), self.nid)
     animal.get_date_brought_in(base.get_dbo(), self.nid)
     animal.get_display_location(base.get_dbo(), self.nid)
     animal.get_display_location_noq(base.get_dbo(), self.nid)
     animal.get_code(base.get_dbo(), self.nid)
     animal.get_short_code(base.get_dbo(), self.nid)
     animal.get_shelter_code(base.get_dbo(), self.nid)
     animal.get_animal_namecode(base.get_dbo(), self.nid)
     assert len(animal.get_recent_changes(base.get_dbo())) > 0
     assert len(animal.get_shelter_animals(base.get_dbo())) > 0
     assert animal.get_number_animals_on_shelter_now(base.get_dbo()) > 0
     assert True == animal.get_has_animals(base.get_dbo())
     assert True == animal.get_has_animal_on_shelter(base.get_dbo())
     animal.get_animals_owned_by(base.get_dbo(), 1)
     animal.get_preferred_web_media_name(base.get_dbo(), self.nid)
Example #3
0
def get_link_info(dbo, linktypeid, linkid):
    """
    Returns the linkinfo string for the id/type
    """
    l = dbo.locale
    if linktypeid == ANIMAL:
        return "%s [%s]" % (animal.get_animal_namecode(dbo, linkid), animal.calc_display_location(dbo, linkid)[0])

    elif linktypeid == PERSON:
        return person.get_person_name(dbo, linkid)

    elif linktypeid == LOSTANIMAL:
        return i18n._("Lost Animal: {0}", l).format(lostfound.get_lost_person_name(dbo, linkid))

    elif linktypeid == FOUNDANIMAL:
        return i18n._("Found Animal: {0}", l).format(lostfound.get_found_person_name(dbo, linkid))

    elif linktypeid == WAITINGLIST:
        return i18n._("Waiting List: {0}", l).format(waitinglist.get_person_name(dbo, linkid))
Example #4
0
def attach_animal(dbo, username, collationid):
    """
    Finds the existing shelter animal with "animalname" and
    attaches the form to it as person media.
    Return value is a tuple of collationid, animalid, animal code/name
    """
    l = dbo.locale
    fields = get_onlineformincoming_detail(dbo, collationid)
    animalname = ""
    for f in fields:
        if f["FIELDNAME"] == "animalname": animalname = f["VALUE"]
    if animalname == "":
        raise utils.ASMValidationError(i18n._("There is not enough information in the form to attach to a shelter animal record (need an animal name).", l))
    # Find the animal
    aid = db.query_int(dbo, "SELECT ID FROM animal WHERE LOWER(AnimalName) LIKE '%s' ORDER BY ID DESC" % animalname.lower())
    if aid == 0:
        raise utils.ASMValidationError(i18n._("Could not find animal with name '{0}'", l).format(animalname))
    formname = get_onlineformincoming_name(dbo, collationid)
    formhtml = get_onlineformincoming_html_print(dbo, [collationid,])
    media.create_document_media(dbo, username, media.ANIMAL, aid, formname, formhtml )
    return (collationid, aid, animal.get_animal_namecode(dbo, aid))
Example #5
0
def get_link_info(dbo, linktypeid, linkid):
    """
    Returns the linkinfo string for the id/type
    """
    l = dbo.locale
    if linktypeid == ANIMAL:
        return "%s [%s]" % (animal.get_animal_namecode(
            dbo, linkid), animal.get_display_location_noq(dbo, linkid))

    elif linktypeid == PERSON:
        return person.get_person_name(dbo, linkid)

    elif linktypeid == LOSTANIMAL:
        return i18n._("Lost Animal: {0}",
                      l).format(lostfound.get_lost_person_name(dbo, linkid))

    elif linktypeid == FOUNDANIMAL:
        return i18n._("Found Animal: {0}",
                      l).format(lostfound.get_found_person_name(dbo, linkid))

    elif linktypeid == WAITINGLIST:
        return i18n._("Waiting List: {0}",
                      l).format(waitinglist.get_person_name(dbo, linkid))
def handler_viewanimal(l, dbo, a, af, diet, vacc, test, med, logs, homelink,
                       post):
    """
    Generate the view animal mobile page.
    l:  The locale
    a:  An animal record
    af: Additional fields for the animal record
    diet: Diets for the animal
    vacc: Vaccinations for the animal
    test: Tests for the animal
    med: Medicals for the animal
    logs: Logs for the animal
    homelink: Link to the home menu
    post: The posted values
    """
    def table():
        return "<table style='width: 100%; border-bottom: 1px solid black;'>"

    def table_end():
        return "</table>"

    def hd(label):
        return "<tr><td style='font-weight: bold; width: 150px'>%s</td></tr>" % label

    def tr(label, value, value2="", value3=""):
        if value is None or str(value).startswith("None "): value = ""
        if value2 is None or str(value2).startswith("None"): value2 = ""
        if value2 is not None and value2 != "": value2 = "<td>%s</td>" % value2
        if value3 is not None and value3 != "": value3 = "<td>%s</td>" % value3
        return "<tr><td style='font-weight: bold; width: 150px'>%s</td><td>%s</td>%s%s</tr>" % (
            label, value, value2, value3)

    h = []
    h.append(header(l))
    h.append(
        jqm_page_header("", "%s - %s" % (a["CODE"], a["ANIMALNAME"]),
                        homelink))
    h.append(table())
    h.append("<tr><td><img src='%s' class='asm-thumbnail' /></td>" %
             html.thumbnail_img_src(a, "animalthumb"))
    h.append("<td><h2 style='margin: 2px;'>%s - %s</h2>" %
             (a["CODE"], a["ANIMALNAME"]))
    h.append("%s %s %s</td>" %
             (a["SEXNAME"], a["BREEDNAME"], a["SPECIESNAME"]))
    h.append("</tr></table>")
    h.append(table())
    uploadstatus = ""
    if post["success"] == "true":
        uploadstatus = _("Photo successfully uploaded.", l)
    h.append("""
        <tr><td style='font-weight: bold; width: 150px;'>%s</td>
        <td>
        <form data-ajax="false" action="mobile_post" method="post" enctype="multipart/form-data">
        <input type="hidden" name="animalid" value="%d" />
        <input type="hidden" name="posttype" value="uai" />
        <input type="hidden" name="comments" value="" />
        <input type="hidden" name="base64image" value="" />
        <input type="file" data-role='none' name="filechooser" id="fc%d" />
        <span class=".tipios6" style="display: none">%s</span>
        <input id='sfc%d' type='submit' data-icon='arrow-u' data-inline='true' data-mini='true' value='%s' />
        </form>
        <span class="tip">%s</span>
        </td></tr>""" %
             (_("Upload Photo", l), a["ID"], a["ID"],
              _("You will need to upgrade to iOS 6 or higher to upload files.",
                l), a["ID"], _("Send", l), uploadstatus))
    h.append(table_end())
    h.append("""
    <script type="text/javascript">
        // If this is an idevice and the file upload box is
        // disabled, it needs upgrading to iOS6 or better.
        if (is_idevice && $("#fc%d").attr("disabled")) {
            $(".tipios6").show();
        }
    </script>
    """ % (a["ID"]))
    h.append(table())
    h.append(tr(_("Type", l), a["ANIMALTYPENAME"]))
    h.append(tr(_("Location", l), a["DISPLAYLOCATIONNAME"]))
    h.append(tr(_("Color", l), a["BASECOLOURNAME"]))
    h.append(tr(_("Coat Type", l), a["COATTYPENAME"]))
    h.append(tr(_("Size", l), a["SIZENAME"]))
    h.append(
        tr(_("DOB", l), python2display(l, a["DATEOFBIRTH"]), a["ANIMALAGE"]))
    h.append(table_end())
    h.append(table())
    h.append(tr(_("Markings", l), a["MARKINGS"]))
    h.append(tr(_("Hidden Comments", l), a["HIDDENANIMALDETAILS"]))
    h.append(tr(_("Comments", l), a["ANIMALCOMMENTS"]))
    h.append(table_end())
    h.append(table())
    h.append(tr(_("Cats", l), a["ISGOODWITHCATSNAME"]))
    h.append(tr(_("Dogs", l), a["ISGOODWITHDOGSNAME"]))
    h.append(tr(_("Children", l), a["ISGOODWITHCHILDRENNAME"]))
    h.append(tr(_("Housetrained", l), a["ISHOUSETRAINEDNAME"]))
    h.append(table_end())
    h.append(table())
    h.append(tr(_("Original Owner", l), a["ORIGINALOWNERNAME"]))
    h.append(tr(_("Brought In By", l), a["BROUGHTINBYOWNERNAME"]))
    h.append(tr(_("Date Brought In", l), python2display(l,
                                                        a["DATEBROUGHTIN"])))
    h.append(
        tr(
            _("Bonded With", l),
            "%s %s %s %s" % (a["BONDEDANIMAL1CODE"], a["BONDEDANIMAL1NAME"],
                             a["BONDEDANIMAL2CODE"], a["BONDEDANIMAL2NAME"])))
    h.append(tr(_("Transfer?", l), a["ISTRANSFERNAME"] == 1))
    h.append(tr(_("Entry Category", l), a["ENTRYREASONNAME"]))
    h.append(tr(_("Entry Reason", l), a["REASONFORENTRY"]))
    h.append(table_end())
    h.append(table())
    h.append(
        tr(_("Microchipped", l), python2display(l, a["IDENTICHIPDATE"]),
           a["IDENTICHIPNUMBER"]))
    h.append(
        tr(_("Tattoo", l), python2display(l, a["TATTOODATE"]),
           a["TATTOONUMBER"]))
    h.append(tr(_("Neutered", l), python2display(l, a["NEUTEREDDATE"])))
    h.append(tr(_("Declawed", l), a["DECLAWEDNAME"]))
    h.append(
        tr(_("Heartworm Tested", l), python2display(l, a["HEARTWORMTESTDATE"]),
           a["HEARTWORMTESTRESULTNAME"]))
    h.append(
        tr(_("FIV/L Tested", l), python2display(l, a["COMBITESTDATE"]),
           "%s %s" % (a["COMBITESTRESULTNAME"], a["FLVRESULTNAME"])))
    h.append(tr(_("Health Problems", l), a["HEALTHPROBLEMS"]))
    h.append(tr(_("Rabies Tag", l), a["RABIESTAG"]))
    h.append(tr(_("Special Needs", l), a["HASSPECIALNEEDSNAME"]))
    h.append(
        tr(_("Current Vet", l), a["CURRENTVETNAME"],
           a["CURRENTVETWORKTELEPHONE"]))
    h.append(table_end())

    if len(af) > 0:
        h.append(table())
        for d in af:
            if d["FIELDTYPE"] == additional.ANIMAL_LOOKUP:
                h.append(
                    tr(d["FIELDLABEL"],
                       animal.get_animal_namecode(dbo,
                                                  utils.cint(d["VALUE"]))))
            elif d["FIELDTYPE"] == additional.PERSON_LOOKUP:
                h.append(
                    tr(
                        d["FIELDLABEL"],
                        person.get_person_name_code(dbo,
                                                    utils.cint(d["VALUE"]))))
            elif d["FIELDTYPE"] == additional.MONEY:
                h.append(tr(d["FIELDLABEL"], format_currency(l, d["VALUE"])))
            elif d["FIELDTYPE"] == additional.YESNO:
                h.append(
                    tr(d["FIELDLABEL"], d["VALUE"] == "1" and _("Yes", l)
                       or _("No", l)))
            else:
                h.append(tr(d["FIELDLABEL"], d["VALUE"]))
        h.append(table_end())

    h.append(table())
    h.append(hd(_("Diet", l)))
    for d in diet:
        h.append(
            tr(python2display(l, d["DATESTARTED"]), d["DIETNAME"],
               d["COMMENTS"]))
    h.append(table_end())

    h.append(table())
    h.append(hd(_("Vaccination", l)))
    for v in vacc:
        h.append(
            tr(python2display(l, v["DATEREQUIRED"]),
               python2display(l, v["DATEOFVACCINATION"]),
               v["VACCINATIONTYPE"]))
    h.append(table_end())

    h.append(table())
    h.append(hd(_("Test", l)))
    for t in test:
        h.append(
            tr(python2display(l, t["DATEREQUIRED"]),
               python2display(l, t["DATEOFTEST"]), t["TESTNAME"],
               t["RESULTNAME"]))
    h.append(table_end())

    h.append(table())
    h.append(hd(_("Medical", l)))
    for m in med:
        h.append(
            tr(python2display(l, m["STARTDATE"]), m["TREATMENTNAME"],
               m["DOSAGE"]))
    h.append(table_end())

    h.append(table())
    h.append(hd(_("Log", l)))
    for lo in logs:
        h.append(
            tr(python2display(l, lo["DATE"]), lo["LOGTYPENAME"],
               lo["COMMENTS"]))
    h.append(table_end())
    h.append(jqm_page_footer())
    h.append("</body></html>")
    return "\n".join(h)