diff demo/more/bid.ur @ 1022:4de35df3d545

Start of bidding implementation compiles
author Adam Chlipala <adamc@hcoop.net>
date Sat, 31 Oct 2009 15:51:50 -0400
parents
children e46227efcbba
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/more/bid.ur	Sat Oct 31 15:51:50 2009 -0400
@@ -0,0 +1,34 @@
+functor Make(M : Conference.INPUT) = struct
+    open M
+
+    table bid : {User : userId, Paper : paperId, Interest : char}
+          PRIMARY KEY (User, Paper)
+
+    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>
+        in
+            <xml>
+              <li> <a link={bid ()}>Bid on papers</a></li>
+            </xml>
+        end
+
+    con yourPaperTables = [Assignment = _]
+    constraint [Paper] ~ yourPaperTables
+    fun joinYourPaper [tabs] [paper] [[Paper] ~ tabs] [[Paper] ~ _] [tabs ~ yourPaperTables] [[Id] ~ paper]
+        (fi : sql_from_items ([Paper = [Id = paperId] ++ paper] ++ tabs)) =
+        sql_inner_join fi (sql_from_table [#Assignment] assignment) (WHERE Paper.Id = Assignment.Paper)
+end