# HG changeset patch # User Adam Chlipala # Date 1256243131 14400 # Node ID 32dbb5636ae75470d7d5b9800e3b529610437bb2 # Parent 16f7cb0891b6bdd94c4bf3634db571d00895cf4a Setting and updating your own review diff -r 16f7cb0891b6 -r 32dbb5636ae7 demo/more/conference.ur --- a/demo/more/conference.ur Thu Oct 22 16:15:56 2009 -0400 +++ b/demo/more/conference.ur Thu Oct 22 16:25:31 2009 -0400 @@ -250,55 +250,73 @@ and one id = - me <- getLogin; - checkPaper id; - ro <- oneOrNoRows (SELECT paper.{{map fst M.paper}}, octet_length(paper.Document) AS N - FROM paper - WHERE paper.Id = {[id]}); - authors <- queryX (SELECT user.Nam - FROM authorship - JOIN user ON authorship.User = user.Id - WHERE authorship.Paper = {[id]}) - (fn r =>
  • {[r.User.Nam]}
  • ); - myReview <- oneOrNoRows1 (SELECT review.{{map fst M.review}} - FROM review - WHERE review.User = {[me.Id]} - AND review.Paper = {[id]}); - case ro of - None => error Paper not found! - | Some r => return -

    Paper #{[id]}

    + let + fun newReview r = + me <- getLogin; + checkPaper id; + dml (insert review ({Paper = sql_inject id, User = sql_inject me.Id} + ++ ensql M.review r M.reviewFolder)); + one id -

    Authors:

    - + fun saveReview r = + me <- getLogin; + checkPaper id; + dml (update [map fst M.review] ! (ensql M.review r M.reviewFolder) + review (WHERE T.Paper = {[id]} AND T.User = {[me.Id]})); + one id + in + me <- getLogin; + checkPaper id; + ro <- oneOrNoRows (SELECT paper.{{map fst M.paper}}, octet_length(paper.Document) AS N + FROM paper + WHERE paper.Id = {[id]}); + authors <- queryX (SELECT user.Nam + FROM authorship + JOIN user ON authorship.User = user.Id + WHERE authorship.Paper = {[id]}) + (fn r =>
  • {[r.User.Nam]}
  • ); + myReview <- oneOrNoRows1 (SELECT review.{{map fst M.review}} + FROM review + WHERE review.User = {[me.Id]} + AND review.Paper = {[id]}); + case ro of + None => error Paper not found! + | Some r => return +

    Paper #{[id]}

    - {allContent M.paper r.Paper M.paperFolder}
    +

    Authors:

    +
      + {authors} +
    - {if r.N = 0 then -
    No paper uploaded yet.
    - else - Download paper ({[r.N]} bytes)} + {allContent M.paper r.Paper M.paperFolder}
    -
    + {if r.N = 0 then +
    No paper uploaded yet.
    + else + Download paper ({[r.N]} bytes)} - {case myReview of - None => -

    Add Your Review

    - -
    - {allWidgets M.review M.reviewFolder} -
    -
    - | Some myReview => -

    Edit Your Review

    +
    -
    - {allPopulated M.review myReview M.reviewFolder} -
    -
    } -
    + {case myReview of + None => +

    Add Your Review

    + +
    + {allWidgets M.review M.reviewFolder} + + +
    + | Some myReview => +

    Edit Your Review

    + +
    + {allPopulated M.review myReview M.reviewFolder} + + +
    } +
    + end and download id = checkPaper id;