From 8eeb0838dd232592ea4bc0e6478f38cd6a68049d Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Tue, 30 Apr 2013 17:54:40 -0400 Subject: Forum: Actually display answers --- forum/forum.ur | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'forum/forum.ur') diff --git a/forum/forum.ur b/forum/forum.ur index 6dc451a..49acd18 100644 --- a/forum/forum.ur +++ b/forum/forum.ur @@ -29,6 +29,7 @@ style entryTitle style entryBody table entry : { Id : int, + References : option int, Class : EntryClass.entryClass, Title : string, Body : string, @@ -45,14 +46,29 @@ val getName : transaction (option string) = fun detail (id : int) : transaction page = authorOpt <- getName; - queryX (SELECT * FROM entry - WHERE Entry.Class = {[EntryClass.question]} - AND Entry.Id = {[id]}) (fn q => - Template.generic (Some "Forum") -
+ questionBlock <- queryX (SELECT * FROM entry + WHERE Entry.Class = {[EntryClass.question]} + AND Entry.Id = {[id]}) (fn q => +

{[q.Entry.Title]}

{[q.Entry.Body]}

Asked by {[q.Entry.Author]}

+
); + answerBlock <- queryX (SELECT * FROM entry + WHERE Entry.Class = {[EntryClass.answer]} + AND Entry.References = {[Some id]}) (fn a => + +

+ {[a.Entry.Body]} + —{[a.Entry.Author]} +

+
); + return ( + Template.generic (Some "Forum") +
+ {questionBlock} + +
{answerBlock}

Your answer

@@ -72,8 +88,9 @@ fun detail (id : int) : transaction page = and reply qId submission = id <- nextval entryIdS; - dml (INSERT INTO entry (Id, Class, Title, Body, Author) + dml (INSERT INTO entry (Id, References, Class, Title, Body, Author) VALUES ({[id]}, + {[Some qId]}, {[EntryClass.answer]}, {[""]}, {[submission.Body]}, @@ -143,8 +160,9 @@ fun main () : transaction page = and ask submission = id <- nextval entryIdS; - dml (INSERT INTO entry (Id, Class, Title, Body, Author) + dml (INSERT INTO entry (Id, References, Class, Title, Body, Author) VALUES ({[id]}, + {[None]}, {[EntryClass.question]}, {[submission.Title]}, {[submission.Body]}, -- cgit v1.2.3