def create_waitinglist(dbo, username, collationid): """ Creates a waitinglist record from the incoming form data with collationid. Also, attaches the form to the waiting list as media. """ l = dbo.locale fields = get_onlineformincoming_detail(dbo, collationid) d = {} d["dateputon"] = i18n.python2display(l, i18n.now(dbo.timezone)) d["urgency"] = "5" for f in fields: if f["FIELDNAME"] == "species": d["species"] = guess_species(dbo, f["VALUE"]) if f["FIELDNAME"] == "description": d["description"] = f["VALUE"] if f["FIELDNAME"] == "reason": d["reasonforwantingtopart"] = f["VALUE"] if not d.has_key("species"): d["species"] = guess_species(dbo, "") # Have we got enough info to create the waiting list record? We need a description if not d.has_key("description"): raise utils.ASMValidationError( i18n._( "There is not enough information in the form to create a waiting list record (need a description).", l)) # We need the person record before we create the waiting list collationid, personid, personname = create_person(dbo, username, collationid) d["owner"] = personid # Create the waiting list wlid = waitinglist.insert_waitinglist_from_form(dbo, d, username) # Attach the form to the waiting list formname = get_onlineformincoming_name(dbo, collationid) formhtml = get_onlineformincoming_html(dbo, collationid) media.create_document_media(dbo, username, media.WAITINGLIST, wlid, formname, formhtml) return (collationid, wlid, utils.padleft(wlid, 6) + " - " + personname)
def create_waitinglist(dbo, username, collationid): """ Creates a waitinglist record from the incoming form data with collationid. Also, attaches the form to the waiting list as media. """ l = dbo.locale fields = get_onlineformincoming_detail(dbo, collationid) d = {} d["dateputon"] = i18n.python2display(l, i18n.now(dbo.timezone)) d["urgency"] = "5" for f in fields: if f["FIELDNAME"] == "species": d["species"] = guess_species(dbo, f["VALUE"]) if f["FIELDNAME"] == "description": d["description"] = f["VALUE"] if f["FIELDNAME"] == "reason": d["reasonforwantingtopart"] = f["VALUE"] if not d.has_key("species"): d["species"] = guess_species(dbo, "") # Have we got enough info to create the waiting list record? We need a description if not d.has_key("description"): raise utils.ASMValidationError(i18n._("There is not enough information in the form to create a waiting list record (need a description).", l)) # We need the person record before we create the waiting list collationid, personid, personname = create_person(dbo, username, collationid) d["owner"] = personid # Create the waiting list wlid = waitinglist.insert_waitinglist_from_form(dbo, d, username) # Attach the form to the waiting list formname = get_onlineformincoming_name(dbo, collationid) formhtml = get_onlineformincoming_html(dbo, collationid) media.create_document_media(dbo, username, media.WAITINGLIST, wlid, formname, formhtml ) return (collationid, wlid, utils.padleft(wlid, 6) + " - " + personname)
def setUp(self): data = { "dateputon": base.today_display(), "description": "Test", "species": "1", "size": "1", "owner": "1", "urgency": "5" } post = utils.PostedData(data, "en") self.wlid = waitinglist.insert_waitinglist_from_form(base.get_dbo(), post, "test")
def setUp(self): data = { "dateputon": base.today_display(), "description": "Test", "species": "1", "size": "1", "owner": "1", "urgency": "5" } post = utils.PostedData(data, "en") self.wlid = waitinglist.insert_waitinglist_from_form( base.get_dbo(), post, "test")
def create_waitinglist_from_found(dbo, username, aid): """ Creates a waiting list entry from a found animal with the id given """ a = db.query(dbo, "SELECT * FROM animalfound WHERE ID = %d" % int(aid))[0] l = dbo.locale data = { "dateputon": python2display(l, now(dbo.timezone)), "description": str(a["DISTFEAT"]), "species": str(a["ANIMALTYPEID"]), "comments": str(a["COMMENTS"]), "owner": str(a["OWNERID"]), "breed1": a["BREEDID"], "breed2": a["BREEDID"], "basecolour": str(a["BASECOLOURID"]), "urgency": str(configuration.waiting_list_default_urgency(dbo)) } nextid = waitinglist.insert_waitinglist_from_form(dbo, data, username) return nextid
def create_waitinglist_from_found(dbo, username, aid): """ Creates a waiting list entry from a found animal with the id given """ a = dbo.first_row( dbo.query("SELECT * FROM animalfound WHERE ID = %d" % int(aid)) ) l = dbo.locale data = { "dateputon": python2display(l, now(dbo.timezone)), "description": str(a["DISTFEAT"]), "species": str(a["ANIMALTYPEID"]), "comments": str(a["COMMENTS"]), "owner": str(a["OWNERID"]), "breed1": a["BREEDID"], "breed2": a["BREEDID"], "basecolour": str(a["BASECOLOURID"]), "urgency": str(configuration.waiting_list_default_urgency(dbo)) } nextid = waitinglist.insert_waitinglist_from_form(dbo, utils.PostedData(data, dbo.locale), username) return nextid