From 890bccbc6286d9e70618a9f4f64c289d407337ce Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 22 Oct 2009 16:25:31 -0400 Subject: Setting and updating your own review --- demo/more/conference.ur | 116 ++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 49 deletions(-) (limited to 'demo/more') diff --git a/demo/more/conference.ur b/demo/more/conference.ur index 72750248..ca5d4a59 100644 --- a/demo/more/conference.ur +++ b/demo/more/conference.ur @@ -250,55 +250,73 @@ functor Make(M : sig 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]}

    - -

    Authors:

    - - - {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} -
    -
    } -
    + 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 + + 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]}

    + +

    Authors:

    + + + {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} + + +
    } +
    + end and download id = checkPaper id; -- cgit v1.2.3