diff options
author | 2009-11-01 10:20:20 -0500 | |
---|---|---|
committer | 2009-11-01 10:20:20 -0500 | |
commit | 86e740bf4d6be8cb24e32fa2857c57eb860c21cf (patch) | |
tree | 09a704610f44afd4ad023245a9f59d901c3c4345 /demo/more/bid.ur | |
parent | e8ec918ad64bb1008ca7a3184d3e647a62d28404 (diff) |
Bidding interface
Diffstat (limited to 'demo/more/bid.ur')
-rw-r--r-- | demo/more/bid.ur | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/demo/more/bid.ur b/demo/more/bid.ur index 5bcaea3a..692f8e14 100644 --- a/demo/more/bid.ur +++ b/demo/more/bid.ur @@ -7,22 +7,51 @@ functor Make(M : Conference.INPUT) = struct table assignment : {User : userId, Paper : paperId} PRIMARY KEY (User, Paper) - fun isOnPc id = - ro <- oneOrNoRows1 (SELECT user.OnPc - FROM user - WHERE user.Id = {[id]}); - return (case ro of - None => False - | Some r => r.OnPc) - val linksForPc = let - fun bid () = - me <- getLogin; - return <xml>Bidding time!</xml> + fun yourBids () = + me <- getPcLogin; + ps <- queryX (SELECT paper.Id, paper.{{M.paper}}, bid.Interest + FROM paper LEFT JOIN bid ON bid.Paper = paper.Id + AND bid.User = {[me.Id]}) + (fn r => <xml><entry> + <hidden{#Paper} value={show r.Paper.Id}/> + {useMore <xml><tr> + <td>{summarizePaper (r.Paper -- #Id)}</td> + <td><select{#Bid}> + {Select.selectChar ((#"-", "No") :: (#"_", "Maybe") :: (#"+", "Yes") :: []) + r.Bid.Interest} + </select></td> + </tr></xml>} + </entry></xml>); + return <xml><body> + <h1>Bid on papers</h1> + + <form> + <subforms{#Papers}><table> + <tr> <th>Paper</th> <th>Your Bid</th> </tr> + {ps} + </table></subforms> + <submit value="Change" action={changeBids}/> + </form> + </body></xml> + + and changeBids r = + me <- getPcLogin; + List.app (fn {Paper = p, Bid = b} => + case b of + "" => return () + | _ => let + val p = readError p + in + (dml (DELETE FROM bid WHERE Paper = {[p]} AND User = {[me.Id]}); + dml (INSERT INTO bid (Paper, User, Interest) + VALUES ({[p]}, {[me.Id]}, {[String.sub b 0]}))) + end) r.Papers; + yourBids () in <xml> - <li> <a link={bid ()}>Bid on papers</a></li> + <li> <a link={yourBids ()}>Bid on papers</a></li> </xml> end |