示例#1
0
def get_waitinglist(dbo,
                    priorityfloor=5,
                    species=-1,
                    addresscontains="",
                    includeremoved=0,
                    namecontains="",
                    descriptioncontains=""):
    """
    Retrieves the waiting list
    priorityfloor: The lowest urgency to show (1 = urgent, 5 = lowest)
    species: A species filter or -1 for all
    addresscontains: A partial address
    includeremoved: Whether or not to include removed entries
    namecontains: A partial name
    descriptioncontains: A partial description
    """
    l = dbo.locale
    ranks = get_waitinglist_ranks(dbo)
    sql = get_waitinglist_query() + " WHERE a.Urgency <= " + str(priorityfloor)
    if includeremoved == 0: sql += " AND a.DateRemovedFromList Is Null"
    if species != -1: sql += " AND a.SpeciesID = " + str(species)
    if addresscontains != "":
        sql += " AND UPPER(OwnerAddress) Like '%" + str(
            addresscontains).upper().replace("'", "`") + "%'"
    if namecontains != "":
        sql += " AND UPPER(OwnerName) Like '%" + str(
            namecontains).upper().replace("'", "`") + "%'"
    if descriptioncontains != "":
        sql += " AND UPPER(AnimalDescription) Like '%" + str(
            descriptioncontains).upper().replace("'", "`") + "%'"
    sql += " ORDER BY a.Urgency, a.DatePutOnList"
    rows = db.query(dbo, sql)
    wlh = configuration.waiting_list_highlights(dbo).split(" ")
    for r in rows:
        r["HIGHLIGHT"] = ""
        for hi in wlh:
            if hi != "":
                if hi.find("|") == -1:
                    wid = hi
                    h = "1"
                else:
                    wid, h = hi.split("|")
                if wid == str(r["WLID"]).strip():
                    r["HIGHLIGHT"] = h
                    break
        if ranks.has_key(r["WLID"]):
            r["RANK"] = ranks[r["WLID"]]
        else:
            r["RANK"] = ""
        r["TIMEONLIST"] = date_diff(l, r["DATEPUTONLIST"], now(dbo.timezone))
    return rows
示例#2
0
文件: waitinglist.py 项目: rutaq/asm3
def get_waitinglist_by_id(dbo, wid):
    """
    Returns a single waitinglist record for the ID given
    """
    l = dbo.locale
    r = dbo.first_row(
        dbo.query(get_waitinglist_query(dbo) + " WHERE a.ID = ?", [wid]))
    if not r: return None
    ranks = get_waitinglist_ranks(dbo)
    if r.WLID in ranks:
        r.RANK = ranks[r.WLID]
    else:
        r.RANK = ""
    r.TIMEONLIST = date_diff(l, r.DATEPUTONLIST, now(dbo.timezone))
    return r
示例#3
0
def get_waitinglist_by_id(dbo, wid):
    """
    Returns a single waitinglist record for the ID given
    """
    l = dbo.locale
    sql = get_waitinglist_query() + " WHERE a.ID = %d" % int(wid)
    rows = db.query(dbo, sql)
    if len(rows) == 0: return None
    r = rows[0]
    ranks = get_waitinglist_ranks(dbo)
    if ranks.has_key(r["WLID"]):
        r["RANK"] = ranks[r["WLID"]]
    else:
        r["RANK"] = ""
    r["TIMEONLIST"] = date_diff(l, r["DATEPUTONLIST"], now(dbo.timezone))
    return r
示例#4
0
def get_waitinglist_by_id(dbo, wid):
    """
    Returns a single waitinglist record for the ID given
    """
    l = dbo.locale
    sql = get_waitinglist_query() + " WHERE a.ID = %d" % int(wid)
    rows = db.query(dbo, sql)
    if len(rows) == 0: return None
    r = rows[0]
    ranks = get_waitinglist_ranks(dbo)
    if ranks.has_key(r["WLID"]):
        r["RANK"] = ranks[r["WLID"]]
    else:
        r["RANK"] = ""
    r["TIMEONLIST"] = date_diff(l, r["DATEPUTONLIST"], now(dbo.timezone))
    return r
示例#5
0
def get_waitinglist(dbo, priorityfloor = 5, species = -1, addresscontains = "", includeremoved = 0, namecontains = "", descriptioncontains = ""):
    """
    Retrieves the waiting list
    priorityfloor: The lowest urgency to show (1 = urgent, 5 = lowest)
    species: A species filter or -1 for all
    addresscontains: A partial address
    includeremoved: Whether or not to include removed entries
    namecontains: A partial name
    descriptioncontains: A partial description
    """
    l = dbo.locale
    ranks = get_waitinglist_ranks(dbo)
    sql = get_waitinglist_query() + " WHERE a.Urgency <= " + str(priorityfloor)
    if includeremoved == 0: sql += " AND a.DateRemovedFromList Is Null"
    if species != -1: sql += " AND a.SpeciesID = " + str(species)
    if addresscontains != "": sql += " AND UPPER(OwnerAddress) Like '%" + str(addresscontains).upper().replace("'", "`") + "%'"
    if namecontains != "": sql += " AND UPPER(OwnerName) Like '%" + str(namecontains).upper().replace("'", "`") + "%'"
    if descriptioncontains != "": sql += " AND UPPER(AnimalDescription) Like '%" + str(descriptioncontains).upper().replace("'", "`") + "%'"
    sql += " ORDER BY a.Urgency, a.DatePutOnList"
    rows = db.query(dbo, sql)
    wlh = configuration.waiting_list_highlights(dbo).split(" ")
    for r in rows:
        r["HIGHLIGHT"] = ""
        for hi in wlh:
            if hi != "":
                if hi.find("|") == -1:
                    wid = hi
                    h = "1"
                else:
                    wid, h = hi.split("|")
                if wid == str(r["WLID"]).strip():
                    r["HIGHLIGHT"] = h
                    break
        if ranks.has_key(r["WLID"]):
            r["RANK"] = ranks[r["WLID"]]
        else:
            r["RANK"] = ""
        r["TIMEONLIST"] = date_diff(l, r["DATEPUTONLIST"], now(dbo.timezone))
    return rows
示例#6
0
文件: waitinglist.py 项目: rutaq/asm3
def get_waitinglist(dbo,
                    priorityfloor=5,
                    species=-1,
                    size=-1,
                    addresscontains="",
                    includeremoved=0,
                    namecontains="",
                    descriptioncontains="",
                    siteid=0):
    """
    Retrieves the waiting list
    priorityfloor: The lowest urgency to show (1 = urgent, 5 = lowest)
    species: A species filter or -1 for all
    size: A size filter or -1 for all
    addresscontains: A partial address
    includeremoved: Whether or not to include removed entries
    namecontains: A partial name
    descriptioncontains: A partial description
    """
    l = dbo.locale

    ands = []
    values = []

    def add(a, v=None):
        ands.append(a)
        if v: values.append(v)

    add("a.Urgency <= ?", priorityfloor)
    if includeremoved == 0: add("a.DateRemovedFromList Is Null")
    if species != -1: add("a.SpeciesID = ?", species)
    if size != -1: add("a.Size = ?", size)
    if addresscontains != "":
        add("UPPER(OwnerAddress) LIKE ?", "%%%s%%" % addresscontains.upper())
    if namecontains != "":
        add("UPPER(OwnerName) LIKE ?", "%%%s%%" % namecontains.upper())
    if descriptioncontains != "":
        add("UPPER(AnimalDescription) LIKE ?",
            "%%%s%%" % descriptioncontains.upper())
    if siteid != 0: add("(o.SiteID = 0 OR o.SiteID = ?)", siteid)

    sql = "%s WHERE %s ORDER BY a.Urgency, a.DatePutOnList" % (
        get_waitinglist_query(dbo), " AND ".join(ands))
    rows = dbo.query(sql, values)

    wlh = configuration.waiting_list_highlights(dbo).split(" ")
    ranks = get_waitinglist_ranks(dbo)
    for r in rows:
        r.HIGHLIGHT = ""
        for hi in wlh:
            if hi != "":
                if hi.find("|") == -1:
                    wid = hi
                    h = "1"
                else:
                    wid, h = hi.split("|")
                if wid == str(r.WLID).strip():
                    r.HIGHLIGHT = h
                    break
        if r.WLID in ranks:
            r.RANK = ranks[r.WLID]
        else:
            r.RANK = ""
        r.TIMEONLIST = date_diff(l, r.DATEPUTONLIST, now(dbo.timezone))
    return rows