From 6aa0cd21ab8b74949d95d375e22dae72a9f35b8c Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 4 Aug 2009 15:44:00 +0000 Subject: [PATCH] Add delete links on poll pages --- poll.mlt | 8 +++++--- poll.sml | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/poll.mlt b/poll.mlt index dac0ede..200c96a 100644 --- a/poll.mlt +++ b/poll.mlt @@ -142,15 +142,15 @@ elseif $"mod" <> "" then end elseif $"del" <> "" then - Group.requireGroupName "poll"; showNormal := false; - val poll = Poll.lookupPoll (Web.stoi ($"del")) %> + val poll = Poll.lookupPoll (Web.stoi ($"del")); + Poll.requireCanModify poll %>

Are you sure you want to delete poll <% Web.html (#title poll) %>?

">Yes, delete <% Web.html (#title poll) %>! <% elseif $"del2" <> "" then - Group.requireGroupName "poll"; val poll = Poll.lookupPoll (Web.stoi ($"del2")); + Poll.requireCanModify poll; Poll.deletePoll (Web.stoi ($"del2")) %>

<% Web.html (#title poll) %> deleted!

@@ -320,6 +320,8 @@ end %> <% if canModify then %>


+

Delete this poll

+

Add a new choice

diff --git a/poll.sml b/poll.sml index 74fcaa9..34868cf 100644 --- a/poll.sml +++ b/poll.sml @@ -177,9 +177,9 @@ fun dateLtNow d = fun canModify (poll : poll) = Group.inGroupName "poll" - orelse (#usr poll = Init.getUserId() - andalso (dateLtNow (#starts poll) - orelse not (#ready poll))) + orelse ((#usr poll = Init.getUserId() + andalso (dateLtNow (#starts poll) + orelse not (#ready poll)))) fun requireCanModify poll = if canModify poll then -- 2.20.1