comparison 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
comparison
equal deleted inserted replaced
1005:c6e948ec79e9 1006:5a0f6ec208ce
6 val paper : $(map meta paper) 6 val paper : $(map meta paper)
7 7
8 con review :: {(Type * Type)} 8 con review :: {(Type * Type)}
9 constraint [Paper, User] ~ review 9 constraint [Paper, User] ~ review
10 val review : $(map meta review) 10 val review : $(map meta review)
11
12 val submissionDeadline : time
11 end) = struct 13 end) = struct
12 14
13 table user : {Id : int, Nam : string, Password : string, Chair : bool, OnPc : bool} 15 table user : {Id : int, Nam : string, Password : string, Chair : bool, OnPc : bool}
14 PRIMARY KEY Id, 16 PRIMARY KEY Id,
15 CONSTRAINT Nam UNIQUE Nam 17 CONSTRAINT Nam UNIQUE Nam
79 <tr> <th>Password:</th> <td><password{#Password}/></td> </tr> 81 <tr> <th>Password:</th> <td><password{#Password}/></td> </tr>
80 <tr> <th><submit action={doRegister}/></th> </tr> 82 <tr> <th><submit action={doRegister}/></th> </tr>
81 </table></form> 83 </table></form>
82 </body></xml> 84 </body></xml>
83 85
84 and main () = 86 and signin r =
87 ro <- oneOrNoRowsE1 (SELECT user.Id AS N
88 FROM user
89 WHERE user.Nam = {[r.Nam]}
90 AND user.Password = {[r.Password]});
91 (case ro of
92 None => return ()
93 | Some id => setCookie login {Id = id, Password = r.Password});
94 m <- main' ();
95 return <xml><body>
96 {case ro of
97 None => <xml><div>Invalid username or password.</div></xml>
98 | _ => <xml/>}
99
100 {m}
101 </body></xml>
102
103 and main' () =
85 me <- checkLogin; 104 me <- checkLogin;
86 return <xml><body> 105 now <- now;
106 return <xml><ul>
87 {case me of 107 {case me of
88 None => <xml><li><a link={register None}>Register for access</a></li></xml> 108 None => <xml>
109 <li><a link={register None}>Register for access</a></li>
110 <li><b>Log in:</b> <form><table>
111 <tr> <th>Username:</th> <td><textbox{#Nam}/></td> </tr>
112 <tr> <th>Password:</th> <td><password{#Password}/></td> </tr>
113 <tr> <th><submit value="Log in" action={signin}/></th> </tr>
114 </table></form></li>
115 </xml>
89 | Some me => <xml> 116 | Some me => <xml>
90 <div>Welcome, {[me.Nam]}!</div> 117 <div>Welcome, {[me.Nam]}!</div>
91 118
92 {if me.Chair then 119 {if me.Chair then
93 <xml><li><a link={Users.main ()}>Manage users</a></li></xml> 120 <xml><li><a link={Users.main ()}>Manage users</a></li></xml>
94 else 121 else
95 <xml/>} 122 <xml/>}
123
124 {if now < M.submissionDeadline then
125 <xml><li>Submit</li></xml>
126 else
127 <xml/>}
96 </xml>} 128 </xml>}
97 </body></xml> 129 </ul></xml>
130
131 and main () =
132 m <- main' ();
133 return <xml><body>{m}</body></xml>
98 134
99 end 135 end