diff 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
line wrap: on
line diff
--- a/demo/more/conference.ur	Thu Oct 22 14:05:48 2009 -0400
+++ b/demo/more/conference.ur	Thu Oct 22 16:15:56 2009 -0400
@@ -9,6 +9,7 @@
                  con review :: {(Type * Type)}
                  constraint [Paper, User] ~ review
                  val review : $(map meta review)
+                 val reviewFolder : folder review
 
                  val submissionDeadline : time
                  val summarizePaper : $(map fst paper) -> xbody
@@ -26,7 +27,7 @@
 
     table authorship : {Paper : int, User : int}
           PRIMARY KEY (Paper, User),
-          CONSTRAINT Paper FOREIGN KEY Paper REFERENCES paper(Id),
+          CONSTRAINT Paper FOREIGN KEY Paper REFERENCES paper(Id) ON DELETE CASCADE,
           CONSTRAINT User FOREIGN KEY User REFERENCES user(Id)
 
     con review = [Paper = int, User = int] ++ map fst M.review
@@ -249,6 +250,7 @@
         </body></xml>
 
     and one id =
+        me <- getLogin;
         checkPaper id;
         ro <- oneOrNoRows (SELECT paper.{{map fst M.paper}}, octet_length(paper.Document) AS N
                            FROM paper
@@ -258,6 +260,10 @@
                              JOIN user ON authorship.User = user.Id
                            WHERE authorship.Paper = {[id]})
                    (fn r => <xml><li>{[r.User.Nam]}</li></xml>);
+        myReview <- oneOrNoRows1 (SELECT review.{{map fst M.review}}
+                                  FROM review
+                                  WHERE review.User = {[me.Id]}
+                                    AND review.Paper = {[id]});
         case ro of
             None => error <xml>Paper not found!</xml>
           | Some r => return <xml><body>
@@ -274,6 +280,24 @@
                  <xml><div>No paper uploaded yet.</div></xml>
              else
                  <xml><a link={download id}>Download paper</a> ({[r.N]} bytes)</xml>}
+
+            <hr/>
+
+            {case myReview of
+                 None => <xml>
+                   <h2>Add Your Review</h2>
+           
+                   <form>
+                     {allWidgets M.review M.reviewFolder}
+                   </form>
+                 </xml>
+               | Some myReview => <xml>
+                 <h2>Edit Your Review</h2>
+
+                 <form>
+                   {allPopulated M.review myReview M.reviewFolder}
+                 </form>
+               </xml>}
           </body></xml>
 
     and download id =