Mercurial > urweb
comparison demo/more/conference.ur @ 1011:16f7cb0891b6
Initial support for char in SQL
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 22 Oct 2009 16:15:56 -0400 |
parents | 6b0f3853cc81 |
children | 32dbb5636ae7 |
comparison
equal
deleted
inserted
replaced
1010:6b0f3853cc81 | 1011:16f7cb0891b6 |
---|---|
7 val paperFolder : folder paper | 7 val paperFolder : folder paper |
8 | 8 |
9 con review :: {(Type * Type)} | 9 con review :: {(Type * Type)} |
10 constraint [Paper, User] ~ review | 10 constraint [Paper, User] ~ review |
11 val review : $(map meta review) | 11 val review : $(map meta review) |
12 val reviewFolder : folder review | |
12 | 13 |
13 val submissionDeadline : time | 14 val submissionDeadline : time |
14 val summarizePaper : $(map fst paper) -> xbody | 15 val summarizePaper : $(map fst paper) -> xbody |
15 end) = struct | 16 end) = struct |
16 | 17 |
24 PRIMARY KEY Id | 25 PRIMARY KEY Id |
25 sequence paperId | 26 sequence paperId |
26 | 27 |
27 table authorship : {Paper : int, User : int} | 28 table authorship : {Paper : int, User : int} |
28 PRIMARY KEY (Paper, User), | 29 PRIMARY KEY (Paper, User), |
29 CONSTRAINT Paper FOREIGN KEY Paper REFERENCES paper(Id), | 30 CONSTRAINT Paper FOREIGN KEY Paper REFERENCES paper(Id) ON DELETE CASCADE, |
30 CONSTRAINT User FOREIGN KEY User REFERENCES user(Id) | 31 CONSTRAINT User FOREIGN KEY User REFERENCES user(Id) |
31 | 32 |
32 con review = [Paper = int, User = int] ++ map fst M.review | 33 con review = [Paper = int, User = int] ++ map fst M.review |
33 table review : review | 34 table review : review |
34 PRIMARY KEY (Paper, User), | 35 PRIMARY KEY (Paper, User), |
247 {ps} | 248 {ps} |
248 </ul> | 249 </ul> |
249 </body></xml> | 250 </body></xml> |
250 | 251 |
251 and one id = | 252 and one id = |
253 me <- getLogin; | |
252 checkPaper id; | 254 checkPaper id; |
253 ro <- oneOrNoRows (SELECT paper.{{map fst M.paper}}, octet_length(paper.Document) AS N | 255 ro <- oneOrNoRows (SELECT paper.{{map fst M.paper}}, octet_length(paper.Document) AS N |
254 FROM paper | 256 FROM paper |
255 WHERE paper.Id = {[id]}); | 257 WHERE paper.Id = {[id]}); |
256 authors <- queryX (SELECT user.Nam | 258 authors <- queryX (SELECT user.Nam |
257 FROM authorship | 259 FROM authorship |
258 JOIN user ON authorship.User = user.Id | 260 JOIN user ON authorship.User = user.Id |
259 WHERE authorship.Paper = {[id]}) | 261 WHERE authorship.Paper = {[id]}) |
260 (fn r => <xml><li>{[r.User.Nam]}</li></xml>); | 262 (fn r => <xml><li>{[r.User.Nam]}</li></xml>); |
263 myReview <- oneOrNoRows1 (SELECT review.{{map fst M.review}} | |
264 FROM review | |
265 WHERE review.User = {[me.Id]} | |
266 AND review.Paper = {[id]}); | |
261 case ro of | 267 case ro of |
262 None => error <xml>Paper not found!</xml> | 268 None => error <xml>Paper not found!</xml> |
263 | Some r => return <xml><body> | 269 | Some r => return <xml><body> |
264 <h1>Paper #{[id]}</h1> | 270 <h1>Paper #{[id]}</h1> |
265 | 271 |
272 | 278 |
273 {if r.N = 0 then | 279 {if r.N = 0 then |
274 <xml><div>No paper uploaded yet.</div></xml> | 280 <xml><div>No paper uploaded yet.</div></xml> |
275 else | 281 else |
276 <xml><a link={download id}>Download paper</a> ({[r.N]} bytes)</xml>} | 282 <xml><a link={download id}>Download paper</a> ({[r.N]} bytes)</xml>} |
283 | |
284 <hr/> | |
285 | |
286 {case myReview of | |
287 None => <xml> | |
288 <h2>Add Your Review</h2> | |
289 | |
290 <form> | |
291 {allWidgets M.review M.reviewFolder} | |
292 </form> | |
293 </xml> | |
294 | Some myReview => <xml> | |
295 <h2>Edit Your Review</h2> | |
296 | |
297 <form> | |
298 {allPopulated M.review myReview M.reviewFolder} | |
299 </form> | |
300 </xml>} | |
277 </body></xml> | 301 </body></xml> |
278 | 302 |
279 and download id = | 303 and download id = |
280 checkPaper id; | 304 checkPaper id; |
281 ro <- oneOrNoRows (SELECT paper.Document | 305 ro <- oneOrNoRows (SELECT paper.Document |