adamc@1022
|
1 signature INPUT = sig
|
adamc@1023
|
2 con paper :: {Type}
|
adamc@1022
|
3 constraint [Id, Document] ~ paper
|
adamc@1022
|
4
|
adamc@1022
|
5 type userId
|
adamc@1022
|
6 val userId_inj : sql_injectable_prim userId
|
adamc@1022
|
7 table user : {Id : userId, Nam : string, Password : string, Chair : bool, OnPc : bool}
|
adamc@1022
|
8 PRIMARY KEY Id,
|
adamc@1022
|
9 CONSTRAINT Nam UNIQUE Nam
|
adamc@1022
|
10
|
adamc@1022
|
11 type paperId
|
adamc@1022
|
12 val paperId_inj : sql_injectable_prim paperId
|
adamc@1023
|
13 val paperId_show : show paperId
|
adamc@1023
|
14 val paperId_read : read paperId
|
adamc@1025
|
15 val paperId_eq : eq paperId
|
adamc@1023
|
16 table paper : ([Id = paperId, Document = blob] ++ paper)
|
adamc@1022
|
17 PRIMARY KEY Id
|
adamc@1022
|
18
|
adamc@1022
|
19 val checkLogin : transaction (option {Id : userId, Nam : string, Chair : bool, OnPc : bool})
|
adamc@1022
|
20 val getLogin : transaction {Id : userId, Nam : string, Chair : bool, OnPc : bool}
|
adamc@1023
|
21 val getPcLogin : transaction {Id : userId, Nam : string, Chair : bool}
|
adamc@1025
|
22 val checkChair : transaction unit
|
adamc@1023
|
23 val summarizePaper : ctx ::: {Unit} -> [[Body] ~ ctx] => $paper -> xml ([Body] ++ ctx) [] []
|
adamc@1022
|
24 end
|
adamc@1022
|
25
|
adamc@1022
|
26 signature OUTPUT = sig
|
adamc@1023
|
27 con paper :: {Type}
|
adamc@1022
|
28 type userId
|
adamc@1022
|
29 type paperId
|
adamc@1022
|
30
|
adamc@1022
|
31 val linksForPc : xbody
|
adamc@1025
|
32 val linksForChair : xbody
|
adamc@1022
|
33
|
adamc@1022
|
34 con yourPaperTables :: {{Type}}
|
adamc@1022
|
35 constraint [Paper] ~ yourPaperTables
|
adamc@1022
|
36 val joinYourPaper : tabs ::: {{Type}} -> paper ::: {Type}
|
adamc@1022
|
37 -> [[Paper] ~ tabs] => [[Paper] ~ yourPaperTables] => [tabs ~ yourPaperTables] => [[Id] ~ paper] =>
|
adamc@1027
|
38 userId
|
adamc@1027
|
39 -> sql_from_items ([Paper = [Id = paperId] ++ paper] ++ tabs)
|
adamc@1022
|
40 -> sql_from_items (yourPaperTables ++ [Paper = [Id = paperId] ++ paper] ++ tabs)
|
adamc@1022
|
41 end
|
adamc@1022
|
42
|
adamc@1004
|
43 open Meta
|
adamc@1001
|
44
|
adamc@1001
|
45 functor Make(M : sig
|
adamc@1003
|
46 con paper :: {(Type * Type)}
|
adamc@1010
|
47 constraint [Id, Document, Authors] ~ paper
|
adamc@1030
|
48 val paper : $(map Meta.meta paper)
|
adamc@1007
|
49 val paperFolder : folder paper
|
adamc@1003
|
50
|
adamc@1030
|
51 con paperPrivate :: {Type}
|
adamc@1030
|
52 constraint [Id, Document, Authors] ~ paperPrivate
|
adamc@1030
|
53 constraint paper ~ paperPrivate
|
adamc@1030
|
54 val paperPrivate : $(map Meta.private paperPrivate)
|
adamc@1030
|
55 val paperPrivateFolder : folder paperPrivate
|
adamc@1030
|
56
|
adamc@1001
|
57 con review :: {(Type * Type)}
|
adamc@1003
|
58 constraint [Paper, User] ~ review
|
adamc@1030
|
59 val review : $(map Meta.meta review)
|
adamc@1011
|
60 val reviewFolder : folder review
|
adamc@1006
|
61
|
adamc@1006
|
62 val submissionDeadline : time
|
adamc@1030
|
63 val summarizePaper : ctx ::: {Unit} -> [[Body] ~ ctx] => $(map fst paper ++ paperPrivate)
|
adamc@1030
|
64 -> xml ([Body] ++ ctx) [] []
|
adamc@1022
|
65
|
adamc@1030
|
66 functor Make (M : INPUT where con paper = map fst paper ++ paperPrivate)
|
adamc@1030
|
67 : OUTPUT where con paper = map fst paper ++ paperPrivate
|
adamc@1023
|
68 where con userId = M.userId
|
adamc@1022
|
69 where con paperId = M.paperId
|
adamc@1001
|
70 end) = struct
|
adamc@1001
|
71
|
adamc@1003
|
72 table user : {Id : int, Nam : string, Password : string, Chair : bool, OnPc : bool}
|
adamc@1003
|
73 PRIMARY KEY Id,
|
adamc@1003
|
74 CONSTRAINT Nam UNIQUE Nam
|
adamc@1003
|
75 sequence userId
|
adamc@1003
|
76
|
adamc@1030
|
77 con paper = [Id = int, Document = blob] ++ map fst M.paper ++ M.paperPrivate
|
adamc@1003
|
78 table paper : paper
|
adamc@1003
|
79 PRIMARY KEY Id
|
adamc@1003
|
80 sequence paperId
|
adamc@1003
|
81
|
adamc@1010
|
82 table authorship : {Paper : int, User : int}
|
adamc@1010
|
83 PRIMARY KEY (Paper, User),
|
adamc@1011
|
84 CONSTRAINT Paper FOREIGN KEY Paper REFERENCES paper(Id) ON DELETE CASCADE,
|
adamc@1010
|
85 CONSTRAINT User FOREIGN KEY User REFERENCES user(Id)
|
adamc@1010
|
86
|
adamc@1003
|
87 con review = [Paper = int, User = int] ++ map fst M.review
|
adamc@1003
|
88 table review : review
|
adamc@1003
|
89 PRIMARY KEY (Paper, User),
|
adamc@1003
|
90 CONSTRAINT Paper FOREIGN KEY Paper REFERENCES paper(Id),
|
adamc@1003
|
91 CONSTRAINT User FOREIGN KEY User REFERENCES user(Id)
|
adamc@1003
|
92 sequence reviewId
|
adamc@1003
|
93
|
adamc@1003
|
94 cookie login : {Id : int, Password : string}
|
adamc@1003
|
95
|
adamc@1004
|
96 val checkLogin =
|
adamc@1003
|
97 r <- getCookie login;
|
adamc@1003
|
98 case r of
|
adamc@1003
|
99 None => return None
|
adamc@1003
|
100 | Some r =>
|
adamc@1003
|
101 oneOrNoRows1 (SELECT user.Id, user.Nam, user.Chair, user.OnPc
|
adamc@1003
|
102 FROM user
|
adamc@1003
|
103 WHERE user.Id = {[r.Id]}
|
adamc@1003
|
104 AND user.Password = {[r.Password]})
|
adamc@1003
|
105
|
adamc@1010
|
106 val getLogin =
|
adamc@1010
|
107 ro <- checkLogin;
|
adamc@1010
|
108 case ro of
|
adamc@1010
|
109 None => error <xml>You must be logged in to do that.</xml>
|
adamc@1010
|
110 | Some r => return r
|
adamc@1010
|
111
|
adamc@1023
|
112 val getPcLogin =
|
adamc@1023
|
113 r <- getLogin;
|
adamc@1023
|
114 if r.OnPc then
|
adamc@1023
|
115 return (r -- #OnPc)
|
adamc@1023
|
116 else
|
adamc@1023
|
117 error <xml>You are not on the PC.</xml>
|
adamc@1023
|
118
|
adamc@1025
|
119 val checkChair =
|
adamc@1025
|
120 r <- getLogin;
|
adamc@1025
|
121 if r.Chair then
|
adamc@1025
|
122 return ()
|
adamc@1025
|
123 else
|
adamc@1025
|
124 error <xml>You are not a chair.</xml>
|
adamc@1025
|
125
|
adamc@1022
|
126 structure O = M.Make(struct
|
adamc@1022
|
127 val user = user
|
adamc@1022
|
128 val paper = paper
|
adamc@1022
|
129 val checkLogin = checkLogin
|
adamc@1022
|
130 val getLogin = getLogin
|
adamc@1023
|
131 val getPcLogin = getPcLogin
|
adamc@1025
|
132 val checkChair = checkChair
|
adamc@1023
|
133 val summarizePaper = @@M.summarizePaper
|
adamc@1022
|
134 end)
|
adamc@1022
|
135
|
adamc@1022
|
136 val checkOnPc =
|
adamc@1022
|
137 r <- getLogin;
|
adamc@1022
|
138 if r.OnPc then
|
adamc@1022
|
139 return ()
|
adamc@1022
|
140 else
|
adamc@1022
|
141 error <xml>You aren't authorized to do that.</xml>
|
adamc@1022
|
142
|
adamc@1009
|
143 fun checkPaper id =
|
adamc@1010
|
144 r <- getLogin;
|
adamc@1010
|
145 if r.OnPc then
|
adamc@1009
|
146 return ()
|
adamc@1009
|
147 else
|
adamc@1010
|
148 error <xml>You aren't authorized to see that paper.</xml>
|
adamc@1009
|
149
|
adamc@1004
|
150 structure Users = BulkEdit.Make(struct
|
adamc@1004
|
151 con keyName = #Id
|
adamc@1004
|
152 val visible = {Nam = string "Name",
|
adamc@1004
|
153 Chair = bool "Chair?",
|
adamc@1004
|
154 OnPc = bool "On PC?"}
|
adamc@1004
|
155
|
adamc@1004
|
156 val title = "Users"
|
adamc@1004
|
157 val isAllowed =
|
adamc@1004
|
158 me <- checkLogin;
|
adamc@1004
|
159 return (Option.isSome me)
|
adamc@1004
|
160
|
adamc@1004
|
161 val t = user
|
adamc@1004
|
162 end)
|
adamc@1004
|
163
|
adamc@1003
|
164 fun doRegister r =
|
adamc@1003
|
165 n <- oneRowE1 (SELECT COUNT( * ) AS N
|
adamc@1003
|
166 FROM user
|
adamc@1003
|
167 WHERE user.Nam = {[r.Nam]});
|
adamc@1003
|
168 if n > 0 then
|
adamc@1003
|
169 register (Some "Sorry; that username is taken.")
|
adamc@1003
|
170 else
|
adamc@1003
|
171 id <- nextval userId;
|
adamc@1003
|
172 dml (INSERT INTO user (Id, Nam, Password, Chair, OnPc)
|
adamc@1003
|
173 VALUES ({[id]}, {[r.Nam]}, {[r.Password]}, FALSE, FALSE));
|
adamc@1003
|
174 setCookie login {Id = id, Password = r.Password};
|
adamc@1003
|
175 main ()
|
adamc@1003
|
176
|
adamc@1003
|
177 and register msg = return <xml><body>
|
adamc@1003
|
178 <h1>Registering a New Account</h1>
|
adamc@1003
|
179
|
adamc@1003
|
180 {case msg of
|
adamc@1003
|
181 None => <xml/>
|
adamc@1003
|
182 | Some msg => <xml><div>{[msg]}</div></xml>}
|
adamc@1003
|
183
|
adamc@1003
|
184 <form><table>
|
adamc@1003
|
185 <tr> <th>Username:</th> <td><textbox{#Nam}/></td> </tr>
|
adamc@1003
|
186 <tr> <th>Password:</th> <td><password{#Password}/></td> </tr>
|
adamc@1003
|
187 <tr> <th><submit action={doRegister}/></th> </tr>
|
adamc@1003
|
188 </table></form>
|
adamc@1003
|
189 </body></xml>
|
adamc@1003
|
190
|
adamc@1006
|
191 and signin r =
|
adamc@1006
|
192 ro <- oneOrNoRowsE1 (SELECT user.Id AS N
|
adamc@1006
|
193 FROM user
|
adamc@1006
|
194 WHERE user.Nam = {[r.Nam]}
|
adamc@1006
|
195 AND user.Password = {[r.Password]});
|
adamc@1006
|
196 (case ro of
|
adamc@1006
|
197 None => return ()
|
adamc@1006
|
198 | Some id => setCookie login {Id = id, Password = r.Password});
|
adamc@1006
|
199 m <- main' ();
|
adamc@1006
|
200 return <xml><body>
|
adamc@1006
|
201 {case ro of
|
adamc@1006
|
202 None => <xml><div>Invalid username or password.</div></xml>
|
adamc@1006
|
203 | _ => <xml/>}
|
adamc@1006
|
204
|
adamc@1006
|
205 {m}
|
adamc@1006
|
206 </body></xml>
|
adamc@1006
|
207
|
adamc@1006
|
208 and main' () =
|
adamc@1004
|
209 me <- checkLogin;
|
adamc@1006
|
210 now <- now;
|
adamc@1006
|
211 return <xml><ul>
|
adamc@1003
|
212 {case me of
|
adamc@1006
|
213 None => <xml>
|
adamc@1006
|
214 <li><a link={register None}>Register for access</a></li>
|
adamc@1006
|
215 <li><b>Log in:</b> <form><table>
|
adamc@1006
|
216 <tr> <th>Username:</th> <td><textbox{#Nam}/></td> </tr>
|
adamc@1006
|
217 <tr> <th>Password:</th> <td><password{#Password}/></td> </tr>
|
adamc@1006
|
218 <tr> <th><submit value="Log in" action={signin}/></th> </tr>
|
adamc@1006
|
219 </table></form></li>
|
adamc@1006
|
220 </xml>
|
adamc@1004
|
221 | Some me => <xml>
|
adamc@1004
|
222 <div>Welcome, {[me.Nam]}!</div>
|
adamc@1004
|
223
|
adamc@1004
|
224 {if me.Chair then
|
adamc@1025
|
225 <xml>
|
adamc@1025
|
226 <li><a link={Users.main ()}>Manage users</a></li>
|
adamc@1025
|
227 {O.linksForChair}
|
adamc@1025
|
228 </xml>
|
adamc@1004
|
229 else
|
adamc@1004
|
230 <xml/>}
|
adamc@1006
|
231
|
adamc@1009
|
232 {if me.OnPc then
|
adamc@1022
|
233 <xml>
|
adamc@1022
|
234 <li><a link={all ()}>All papers</a></li>
|
adamc@1023
|
235 <li><a link={your ()}>Your papers</a></li>
|
adamc@1022
|
236 {O.linksForPc}
|
adamc@1022
|
237 </xml>
|
adamc@1009
|
238 else
|
adamc@1009
|
239 <xml/>}
|
adamc@1009
|
240
|
adamc@1006
|
241 {if now < M.submissionDeadline then
|
adamc@1007
|
242 <xml><li><a link={submit ()}>Submit</a></li></xml>
|
adamc@1006
|
243 else
|
adamc@1006
|
244 <xml/>}
|
adamc@1004
|
245 </xml>}
|
adamc@1006
|
246 </ul></xml>
|
adamc@1006
|
247
|
adamc@1006
|
248 and main () =
|
adamc@1006
|
249 m <- main' ();
|
adamc@1006
|
250 return <xml><body>{m}</body></xml>
|
adamc@1001
|
251
|
adamc@1008
|
252 and submit () =
|
adamc@1008
|
253 let
|
adamc@1009
|
254 fun doSubmit r =
|
adamc@1010
|
255 me <- getLogin;
|
adamc@1010
|
256 coauthors <- List.mapM (fn name => oneOrNoRowsE1 (SELECT user.Id AS N
|
adamc@1010
|
257 FROM user
|
adamc@1010
|
258 WHERE user.Nam = {[name.Nam]})) r.Authors;
|
adamc@1010
|
259 if List.exists Option.isNone coauthors then
|
adamc@1010
|
260 error <xml>At least one of those coauthor usernames isn't registered.</xml>
|
adamc@1010
|
261 else
|
adamc@1010
|
262 id <- nextval paperId;
|
adamc@1010
|
263 dml (insert paper ({Id = sql_inject id, Document = sql_inject (fileData r.Document)}
|
adamc@1030
|
264 ++ ensql M.paper (r -- #Authors -- #Document) M.paperFolder
|
adamc@1030
|
265 ++ initialize M.paperPrivate M.paperPrivateFolder));
|
adamc@1010
|
266 List.app (fn uid =>
|
adamc@1010
|
267 case uid of
|
adamc@1010
|
268 None => error <xml>Impossible empty uid!</xml>
|
adamc@1010
|
269 | Some uid => dml (INSERT INTO authorship (Paper, User)
|
adamc@1010
|
270 VALUES ({[id]}, {[uid]})))
|
adamc@1010
|
271 (Some me.Id :: coauthors);
|
adamc@1010
|
272 return <xml><body>
|
adamc@1010
|
273 Thanks for submitting!
|
adamc@1010
|
274 </body></xml>
|
adamc@1008
|
275 in
|
adamc@1010
|
276 me <- getLogin;
|
adamc@1015
|
277 numAuthors <- Dnat.zero;
|
adamc@1010
|
278
|
adamc@1008
|
279 return <xml><body>
|
adamc@1008
|
280 <h1>Submit a Paper</h1>
|
adamc@1008
|
281
|
adamc@1008
|
282 <form>
|
adamc@1010
|
283 <b>Author:</b> {[me.Nam]}<br/>
|
adamc@1010
|
284 <subforms{#Authors}>
|
adamc@1015
|
285 {Dnat.render <xml><entry><b>Author:</b> <textbox{#Nam}/><br/></entry></xml> numAuthors}
|
adamc@1010
|
286 </subforms>
|
adamc@1015
|
287 <button value="Add author" onclick={Dnat.inc numAuthors}/><br/>
|
adamc@1015
|
288 <button value="Remove author" onclick={Dnat.dec numAuthors}/><br/>
|
adamc@1010
|
289 <br/>
|
adamc@1010
|
290
|
adamc@1010
|
291 {useMore (allWidgets M.paper M.paperFolder)}
|
adamc@1008
|
292 <b>Paper:</b> <upload{#Document}/><br/>
|
adamc@1008
|
293 <submit value="Submit" action={doSubmit}/>
|
adamc@1008
|
294 </form>
|
adamc@1008
|
295 </body></xml>
|
adamc@1008
|
296 end
|
adamc@1007
|
297
|
adamc@1030
|
298 and listPapers [tabs] [[Paper] ~ tabs]
|
adamc@1030
|
299 (q : sql_query ([Paper = [Id = int] ++ map fst M.paper ++ M.paperPrivate] ++ tabs) []) =
|
adamc@1022
|
300 checkOnPc;
|
adamc@1022
|
301 ps <- queryX q
|
adamc@1030
|
302 (fn r => <xml><li><a link={one r.Paper.Id}>{M.summarizePaper (r.Paper -- #Id)}</a>
|
adamc@1030
|
303 </li></xml>);
|
adamc@1009
|
304 return <xml><body>
|
adamc@1009
|
305 <h1>All Papers</h1>
|
adamc@1022
|
306
|
adamc@1009
|
307 <ul>
|
adamc@1009
|
308 {ps}
|
adamc@1009
|
309 </ul>
|
adamc@1009
|
310 </body></xml>
|
adamc@1009
|
311
|
adamc@1022
|
312 and all () =
|
adamc@1022
|
313 checkOnPc;
|
adamc@1030
|
314 listPapers (SELECT paper.Id, paper.{{map fst M.paper ++ M.paperPrivate}} FROM paper)
|
adamc@1022
|
315
|
adamc@1022
|
316 and your () =
|
adamc@1022
|
317 me <- getLogin;
|
adamc@1022
|
318 listPapers (sql_query {Rows = sql_query1 {Distinct = False,
|
adamc@1027
|
319 From = O.joinYourPaper me.Id (sql_from_table [#Paper] paper),
|
adamc@1022
|
320 Where = (WHERE TRUE),
|
adamc@1022
|
321 GroupBy = sql_subset_all [_],
|
adamc@1022
|
322 Having = (WHERE TRUE),
|
adamc@1030
|
323 SelectFields = sql_subset [[Paper =
|
adamc@1030
|
324 ([Id = _]
|
adamc@1030
|
325 ++ map fst M.paper
|
adamc@1030
|
326 ++ M.paperPrivate, _)]
|
adamc@1022
|
327 ++ map (fn ts => ([], ts))
|
adamc@1022
|
328 O.yourPaperTables],
|
adamc@1022
|
329 SelectExps = {}},
|
adamc@1022
|
330 OrderBy = sql_order_by_Nil [_],
|
adamc@1022
|
331 Limit = sql_no_limit,
|
adamc@1022
|
332 Offset = sql_no_offset})
|
adamc@1022
|
333
|
adamc@1009
|
334 and one id =
|
adamc@1012
|
335 let
|
adamc@1012
|
336 fun newReview r =
|
adamc@1012
|
337 me <- getLogin;
|
adamc@1012
|
338 checkPaper id;
|
adamc@1012
|
339 dml (insert review ({Paper = sql_inject id, User = sql_inject me.Id}
|
adamc@1012
|
340 ++ ensql M.review r M.reviewFolder));
|
adamc@1012
|
341 one id
|
adamc@1009
|
342
|
adamc@1012
|
343 fun saveReview r =
|
adamc@1012
|
344 me <- getLogin;
|
adamc@1012
|
345 checkPaper id;
|
adamc@1012
|
346 dml (update [map fst M.review] ! (ensql M.review r M.reviewFolder)
|
adamc@1012
|
347 review (WHERE T.Paper = {[id]} AND T.User = {[me.Id]}));
|
adamc@1012
|
348 one id
|
adamc@1012
|
349 in
|
adamc@1012
|
350 me <- getLogin;
|
adamc@1012
|
351 checkPaper id;
|
adamc@1012
|
352 ro <- oneOrNoRows (SELECT paper.{{map fst M.paper}}, octet_length(paper.Document) AS N
|
adamc@1012
|
353 FROM paper
|
adamc@1012
|
354 WHERE paper.Id = {[id]});
|
adamc@1012
|
355 authors <- queryX (SELECT user.Nam
|
adamc@1012
|
356 FROM authorship
|
adamc@1012
|
357 JOIN user ON authorship.User = user.Id
|
adamc@1012
|
358 WHERE authorship.Paper = {[id]})
|
adamc@1012
|
359 (fn r => <xml><li>{[r.User.Nam]}</li></xml>);
|
adamc@1012
|
360 myReview <- oneOrNoRows1 (SELECT review.{{map fst M.review}}
|
adamc@1012
|
361 FROM review
|
adamc@1012
|
362 WHERE review.User = {[me.Id]}
|
adamc@1012
|
363 AND review.Paper = {[id]});
|
adamc@1029
|
364 otherReviews <- queryX (SELECT user.Nam, review.{{map fst M.review}}
|
adamc@1029
|
365 FROM review JOIN user ON review.User = user.Id
|
adamc@1029
|
366 WHERE review.Paper = {[id]}
|
adamc@1029
|
367 AND review.User <> {[me.Id]})
|
adamc@1029
|
368 (fn r => <xml>
|
adamc@1029
|
369 <hr/>
|
adamc@1029
|
370 <b>User:</b> {[r.User.Nam]}<br/>
|
adamc@1029
|
371 {allContent M.review r.Review M.reviewFolder}
|
adamc@1029
|
372 </xml>);
|
adamc@1029
|
373
|
adamc@1012
|
374 case ro of
|
adamc@1012
|
375 None => error <xml>Paper not found!</xml>
|
adamc@1012
|
376 | Some r => return <xml><body>
|
adamc@1012
|
377 <h1>Paper #{[id]}</h1>
|
adamc@1010
|
378
|
adamc@1012
|
379 <h3>Authors:</h3>
|
adamc@1012
|
380 <ul>
|
adamc@1012
|
381 {authors}
|
adamc@1012
|
382 </ul>
|
adamc@1009
|
383
|
adamc@1012
|
384 {allContent M.paper r.Paper M.paperFolder}<br/>
|
adamc@1011
|
385
|
adamc@1012
|
386 {if r.N = 0 then
|
adamc@1012
|
387 <xml><div>No paper uploaded yet.</div></xml>
|
adamc@1012
|
388 else
|
adamc@1012
|
389 <xml><a link={download id}>Download paper</a> ({[r.N]} bytes)</xml>}
|
adamc@1011
|
390
|
adamc@1012
|
391 <hr/>
|
adamc@1011
|
392
|
adamc@1012
|
393 {case myReview of
|
adamc@1012
|
394 None => <xml>
|
adamc@1012
|
395 <h2>Add Your Review</h2>
|
adamc@1012
|
396
|
adamc@1012
|
397 <form>
|
adamc@1012
|
398 {allWidgets M.review M.reviewFolder}
|
adamc@1012
|
399 <submit value="Add" action={newReview}/>
|
adamc@1012
|
400 </form>
|
adamc@1012
|
401 </xml>
|
adamc@1012
|
402 | Some myReview => <xml>
|
adamc@1012
|
403 <h2>Edit Your Review</h2>
|
adamc@1012
|
404
|
adamc@1012
|
405 <form>
|
adamc@1012
|
406 {allPopulated M.review myReview M.reviewFolder}
|
adamc@1012
|
407 <submit value="Save" action={saveReview}/>
|
adamc@1012
|
408 </form>
|
adamc@1012
|
409 </xml>}
|
adamc@1029
|
410
|
adamc@1029
|
411 <hr/>
|
adamc@1029
|
412 <h2>Other reviews</h2>
|
adamc@1029
|
413
|
adamc@1029
|
414 {otherReviews}
|
adamc@1012
|
415 </body></xml>
|
adamc@1012
|
416 end
|
adamc@1009
|
417
|
adamc@1009
|
418 and download id =
|
adamc@1009
|
419 checkPaper id;
|
adamc@1009
|
420 ro <- oneOrNoRows (SELECT paper.Document
|
adamc@1009
|
421 FROM paper
|
adamc@1009
|
422 WHERE paper.Id = {[id]});
|
adamc@1009
|
423 case ro of
|
adamc@1009
|
424 None => error <xml>Paper not found!</xml>
|
adamc@1009
|
425 | Some r => returnBlob r.Paper.Document (blessMime "application/pdf")
|
adamc@1009
|
426
|
adamc@1001
|
427 end
|
adamc@1030
|
428
|
adamc@1030
|
429
|
adamc@1030
|
430 functor Join(M : sig
|
adamc@1030
|
431 structure O1 : OUTPUT
|
adamc@1030
|
432
|
adamc@1030
|
433 structure O2 : OUTPUT where con paper = O1.paper
|
adamc@1030
|
434 where con userId = O1.userId
|
adamc@1030
|
435 where con paperId = O1.paperId
|
adamc@1030
|
436
|
adamc@1030
|
437 constraint O1.yourPaperTables ~ O2.yourPaperTables
|
adamc@1030
|
438 end)
|
adamc@1030
|
439 = struct
|
adamc@1030
|
440 open M
|
adamc@1030
|
441 open O1
|
adamc@1030
|
442
|
adamc@1030
|
443 val linksForPc = <xml>{O1.linksForPc}{O2.linksForPc}</xml>
|
adamc@1030
|
444 val linksForChair = <xml>{O1.linksForChair}{O2.linksForChair}</xml>
|
adamc@1030
|
445
|
adamc@1030
|
446 con yourPaperTables = O1.yourPaperTables ++ O2.yourPaperTables
|
adamc@1030
|
447 constraint [Paper] ~ yourPaperTables
|
adamc@1030
|
448
|
adamc@1030
|
449 fun joinYourPaper [tabs] [paper] [[Paper] ~ tabs] [[Paper] ~ _] [tabs ~ yourPaperTables] [[Id] ~ paper]
|
adamc@1030
|
450 uid (fi : sql_from_items ([Paper = [Id = paperId] ++ paper] ++ tabs)) =
|
adamc@1030
|
451 O2.joinYourPaper uid (O1.joinYourPaper uid fi)
|
adamc@1030
|
452 end
|