diff demo/more/conference.ur @ 1006:5a0f6ec208ce

Checking deadline; sign-in
author Adam Chlipala <adamc@hcoop.net>
date Thu, 22 Oct 2009 11:15:37 -0400
parents a87495bcaeec
children d3af9e54c828
line wrap: on
line diff
--- a/demo/more/conference.ur	Tue Oct 20 13:08:42 2009 -0400
+++ b/demo/more/conference.ur	Thu Oct 22 11:15:37 2009 -0400
@@ -8,6 +8,8 @@
                  con review :: {(Type * Type)}
                  constraint [Paper, User] ~ review
                  val review : $(map meta review)
+
+                 val submissionDeadline : time
              end) = struct
 
     table user : {Id : int, Nam : string, Password : string, Chair : bool, OnPc : bool}
@@ -81,11 +83,36 @@
       </table></form>
     </body></xml>
 
-    and main () =
+    and signin r =
+        ro <- oneOrNoRowsE1 (SELECT user.Id AS N
+                             FROM user
+                             WHERE user.Nam = {[r.Nam]}
+                               AND user.Password = {[r.Password]});
+        (case ro of
+             None => return ()
+           | Some id => setCookie login {Id = id, Password = r.Password});
+        m <- main' ();
+        return <xml><body>
+          {case ro of
+               None => <xml><div>Invalid username or password.</div></xml>
+             | _ => <xml/>}
+
+          {m}
+        </body></xml>
+
+    and main' () =
         me <- checkLogin;
-        return <xml><body>
+        now <- now;
+        return <xml><ul>
           {case me of
-               None => <xml><li><a link={register None}>Register for access</a></li></xml>
+               None => <xml>
+                 <li><a link={register None}>Register for access</a></li>
+                 <li><b>Log in:</b> <form><table>
+                   <tr> <th>Username:</th> <td><textbox{#Nam}/></td> </tr>
+                   <tr> <th>Password:</th> <td><password{#Password}/></td> </tr>
+                   <tr> <th><submit value="Log in" action={signin}/></th> </tr>
+                 </table></form></li>
+               </xml>
              | Some me => <xml>
                <div>Welcome, {[me.Nam]}!</div>
 
@@ -93,7 +120,16 @@
                     <xml><li><a link={Users.main ()}>Manage users</a></li></xml>
                 else
                     <xml/>}
+
+               {if now < M.submissionDeadline then
+                    <xml><li>Submit</li></xml>
+                else
+                    <xml/>}
              </xml>}
-        </body></xml>
+        </ul></xml>
+
+    and main () =
+        m <- main' ();
+        return <xml><body>{m}</body></xml>
 
 end