X-Git-Url: https://git.hcoop.net/hcoop/zz_old/portal.git/blobdiff_plain/57c305c1681b8b819d90b3f5a4d8c77a03926a4e..45174231c9693be788280cc80acc5e28394e35bf:/poll.mlt
diff --git a/poll.mlt b/poll.mlt
index 19e1eba..505044f 100644
--- a/poll.mlt
+++ b/poll.mlt
@@ -8,7 +8,7 @@ ref showNormal = true;
if $"cmd" = "list" then
showNormal := false %>
-
All polls
+All polls
<% foreach pol in Poll.listPolls () do %>
<% Web.html (#title pol) %>
@@ -16,23 +16,72 @@ if $"cmd" = "list" then
<% end
+elseif $"vote" <> "" then
+ showNormal := false;
+ val id = Web.stoi ($"vote");
+ val poll = Poll.lookupPoll id %>
+
+
+ Poll#: | <% id %> |
+ Title: | <% Web.html (#title poll) %> |
+ Start: | <% Web.html (#starts poll) %> |
+ End: | <% Web.html (#ends poll) %> |
+ Votes/person: | <% #votes poll %> |
+ Description: | <% Web.htmlNl (#descr poll) %> |
+
+
+Choices
+
+
+
+<% elseif $"vote2" <> "" then
+ val id = Web.stoi ($"vote2");
+ val poll = Poll.lookupPoll id;
+ editingPoll := SOME id;
+
+ val votes = case Web.getMultiParam "v" of
+ [""] => []
+ | v => map Web.stoi v;
+
+ if length votes > #votes poll then
+ %>You can't vote for that many different choices!
<%
+ elseif not (Poll.noDupes votes) then
+ %>You can't vote multiple times for the same choice!
<%
+ else
+ Poll.vote (Init.getUserId (), id, votes)
+ %>Thanks for voting!
+<% end
+
elseif $"cmd" = "add" then
val title = $"title";
val starts = $"starts";
val ends = $"ends";
val votes = Web.stoi ($"votes");
if title = "" then
- %>Your poll must have a title.
<%
- elseif not (Poll.dateGeNow starts) then
- %>That start date is in the past!
<%
- elseif not (Poll.dateLe (starts, ends)) then
- %>The end date comes before the start date!
<%
+ %>Your poll must have a title.
<%
+ elseif not pollAdmin and not (Poll.dateGeNow starts) then
+ %>That start date is in the past!
<%
+ elseif not pollAdmin and not (Poll.dateLe (starts, ends)) then
+ %>The end date comes before the start date!
<%
elseif votes <= 0 then
- %>You must specify a positive number of votes per person.
<%
+ %>You must specify a positive number of votes per person.
<%
else
val id = Poll.addPoll (Init.getUserId(), title, $"descr", starts, ends, votes);
editingPoll := SOME id;
- %>Poll added!
<%
+ %>Poll added!
<%
end
elseif $"mod" <> "" then
@@ -40,16 +89,16 @@ elseif $"mod" <> "" then
val poll = Poll.lookupPoll (Web.stoi ($"mod"));
Poll.requireCanModify poll %>
-Modify poll
+Modify poll
-