X-Git-Url: https://git.hcoop.net/hcoop/portal.git/blobdiff_plain/b90b0980f97ea3c9623f99db83abeb7419b916b2..34bc3b831fe9636352043dbc15e9078c319f3fb8:/poll.mlt
diff --git a/poll.mlt b/poll.mlt
index b216a4f..200c96a 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) %>
@@ -21,18 +21,22 @@ elseif $"vote" <> "" then
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) %> |
+
+ Poll#: | <% id %> |
+ Title: | <% Web.html (#title poll) %> |
+ Start: | <% Web.html (#starts poll) %> |
+ End: | <% Web.html (#ends poll) %> |
+ Votes/person: | <% #votes poll %> |
+ Official: | <% if #official poll then "yes" else "no" end %> |
+ Description: | <% Web.htmlNl (#descr poll) %> |
-Choices
+<% if #official poll and Poll.membershipLength (Init.getUserId ()) < Poll.votingMembershipRequirement then %>
+ You haven't been a member long enough to vote in an official poll.
+<% else %>
+Choices
-
-<% elseif $"vote2" <> "" then
+<% end
+elseif $"vote2" <> "" then
val id = Web.stoi ($"vote2");
val poll = Poll.lookupPoll id;
editingPoll := SOME id;
@@ -56,13 +61,15 @@ foreach (you, cho) in choices do %>
[""] => []
| v => map Web.stoi v;
- if length votes > #votes poll then
- %>You can't vote for that many different choices!
<%
+ if #official poll and Poll.membershipLength (Init.getUserId ()) < Poll.votingMembershipRequirement then
+ %>You haven't been a member long enough to vote in an official poll.
<%
+ elseif 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!
<%
+ %>You can't vote multiple times for the same choice!
<%
else
Poll.vote (Init.getUserId (), id, votes)
- %>Thanks for voting!
+ %>Thanks for voting!
<% end
elseif $"cmd" = "add" then
@@ -70,18 +77,19 @@ elseif $"cmd" = "add" then
val starts = $"starts";
val ends = $"ends";
val votes = Web.stoi ($"votes");
+ val official = $"official" = "on";
if title = "" then
- %>Your poll must have a title.
<%
+ %>Your poll must have a title.
<%
elseif not pollAdmin and not (Poll.dateGeNow starts) then
- %>That start date is in the past!
<%
+ %>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!
<%
+ %>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);
+ val id = Poll.addPoll (Init.getUserId(), title, $"descr", starts, ends, votes, official, false);
editingPoll := SOME id;
- %>Poll added!
<%
+ %>Poll added!
<%
end
elseif $"mod" <> "" then
@@ -89,16 +97,18 @@ elseif $"mod" <> "" then
val poll = Poll.lookupPoll (Web.stoi ($"mod"));
Poll.requireCanModify poll %>
-Modify poll
+Modify poll
-