<tr> <td>Start:</td> <td><% Web.html (#starts poll) %></td> </tr>
<tr> <td>End:</td> <td><% Web.html (#ends poll) %></td> </tr>
<tr> <td>Votes/person:</td> <td><% #votes poll %></td> </tr>
+<tr> <td>Official:</td> <td><% if #official poll then "yes" else "no" end %></td> </tr>
<tr> <td>Description:</td> <td><% Web.htmlNl (#descr poll) %></td> </tr>
</table>
+<% if #official poll and Poll.membershipLength (Init.getUserId ()) < Poll.votingMembershipRequirement then %>
+ <h3>You haven't been a member long enough to vote in an official poll.</h3>
+<% else %>
<h3>Choices</h3>
<form action="poll" method="post">
<input type="submit" value="Vote">
</form>
-<% elseif $"vote2" <> "" then
+<% end
+elseif $"vote2" <> "" then
val id = Web.stoi ($"vote2");
val poll = Poll.lookupPoll id;
editingPoll := SOME id;
[""] => []
| v => map Web.stoi v;
- if length votes > #votes poll then
+ if #official poll and Poll.membershipLength (Init.getUserId ()) < Poll.votingMembershipRequirement then
+ %><h3>You haven't been a member long enough to vote in an official poll.</h3><%
+ elseif length votes > #votes poll then
%><h3>You can't vote for that many different choices!</h3><%
elseif not (Poll.noDupes votes) then
%><h3>You can't vote multiple times for the same choice!</h3><%
val starts = $"starts";
val ends = $"ends";
val votes = Web.stoi ($"votes");
+ val official = $"official" = "on";
if title = "" then
%><h3>Your poll must have a title.</h3><%
elseif not pollAdmin and not (Poll.dateGeNow starts) then
elseif votes <= 0 then
%><h3>You must specify a positive number of votes per person.</h3><%
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;
%><h3>Poll added!</h3><%
end
<input type="hidden" name="id" value="<% $"mod" %>">
<table class="blanks">
<tr> <td>Title:</td> <td><input name="title" value="<% Web.html (#title poll) %>"></td> </tr>
+<tr> <td>Ready?</td> <td><input type="checkbox" name="ready" <% if #ready poll then " checked" else "" end %>></td> </tr>
<tr> <td>Start date:</td> <td><input name="starts" value="<% Web.html (#starts poll) %>"></td> </tr>
<tr> <td>End date:</td> <td><input name="ends" value="<% Web.html (#ends poll) %>"></td> </tr>
<tr> <td>Max votes/person:</td> <td><input name="votes" value="<% #votes poll %>"></td> </tr>
+<tr> <td>Official:</td> <td><input type="checkbox" name="official"<% if #official poll then " checked" end %>></td> </tr>
<tr> <td>Description:</td> <td><textarea name="descr" wrap="soft" rows="5" cols="80"><% Web.html (#descr poll) %></textarea></td> </tr>
<tr> <td><input type="submit" name="cmd" value="Save"></td> </tr>
</table>
val starts = $"starts";
val ends = $"ends";
val votes = Web.stoi ($"votes");
- if title = "" then
+ val official = $"official" = "on";
+ val ready = $"ready" = "on";
+ if not (Poll.canModify poll) then
+ %><h3>You can't modify this poll anymore, because voting is already open.</h3><%
+ elseif title = "" then
%><h3>Your poll must have a title.</h3><%
elseif not pollAdmin and not (Poll.dateGeNow starts) then
%><h3>That start date is in the past!</h3><%
elseif votes <= 0 then
%><h3>You must specify a positive number of votes per person.</h3><%
else
- Poll.modPoll {poll with title = title, descr = $"descr", starts = starts, ends = ends, votes = votes};
+ Poll.modPoll {poll with title = title, descr = $"descr", starts = starts, ends = ends, votes = votes, official = official,
+ ready = ready};
editingPoll := SOME (#id poll);
%><h3>Poll record saved.</h3><%
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 %>
<h3>Are you sure you want to delete poll <a href="poll?id=<% #id poll %>"><% Web.html (#title poll) %></a>?</h3>
<a href="poll?del2=<% $"del" %>">Yes, delete <% Web.html (#title poll) %>!</a>
<% elseif $"del2" <> "" then
- Group.requireGroupName "poll";
val poll = Poll.lookupPoll (Web.stoi ($"del2"));
+ Poll.requireCanModify poll;
Poll.deletePoll (Web.stoi ($"del2")) %>
<h3><% Web.html (#title poll) %> deleted!</h3>
val id = Web.stoi ($"addChoice");
editingPoll := SOME id;
val descr = $"descr";
- if descr = "" then
+ val poll = Poll.lookupPoll id;
+ if not (Poll.canModify poll) then
+ %><h3>You can't modify this poll anymore, because voting is already open.</h3><%
+ elseif descr = "" then
%><h3>Your poll choice must have a description.</h3><%
else
val id = Poll.addChoice (id, Web.stor ($"seq"), descr);
<table class="blanks">
<tr> <td>Poll#</b>:</td> <td><% id %></td> </tr>
<tr> <td>Title</b>:</td> <td><% Web.html (#title poll) %></td> </tr>
-<tr> <td>Start>:</td> <td><% Web.html (#starts poll) %></td> </tr>
+<tr> <td>Start:</td> <td><% Web.html (#starts poll) %></td> </tr>
<tr> <td>End:</td> <td><% Web.html (#ends poll) %></td> </tr>
<tr> <td>Votes/person:</td> <td><% #votes poll %></td> </tr>
+<tr> <td>Official:</td> <td><% if #official poll then "yes" else "no" end %></td> </tr>
<tr> <td>Description:</td> <td><% Web.htmlNl (#descr poll) %></td> </tr>
</table>
<tr> <td>Start:</td> <td><% Web.html (#starts poll) %></td> </tr>
<tr> <td>End:</td> <td><% Web.html (#ends poll) %></td> </tr>
<tr> <td>Votes/person:</td> <td><% #votes poll %></td> </tr>
+<tr> <td>Official:</td> <td><% if #official poll then "yes" else "no" end %></td> </tr>
<tr> <td>Description:</td> <td><% Web.htmlNl (#descr poll) %></td> </tr>
</table>
<% if canModify then %>
<br><hr><br>
+<h3><a href="?del=<% id %>">Delete this poll</a></h3>
+
<h3>Add a new choice</h3>
<form action="poll" method="post">
<% end %>
<% | NONE =>
-if showNormal then %>
+if showNormal then
+
+val mlen = Poll.membershipLength (Init.getUserId ()) %>
+
+<p>You have been an HCoop member for <% mlen %> days, so you <b>are<% if mlen < Poll.votingMembershipRequirement then %> not<% end %></b> eligible to vote in official polls.</p>
+
+<% val polls = Poll.listCurrentPolls ();
+switch polls of
+ _::_ => %>
+<h3><a href="poll">Current polls</a></h3>
+
+<% foreach pol in polls do %>
+<li> <a href="poll?id=<% #id pol %>"><% Web.html (#title pol) %></a>
+<% if Poll.takingVotes pol then %><a href="poll?vote=<% #id pol %>">[VOTE]</a><% end %>
+(<% Web.html (#starts pol) %> to <% Web.html (#ends pol) %>)</li>
+<% end
+end %>
-<a href="poll?cmd=list">Show all polls</a><br>
+<p><a href="poll?cmd=list">Show all polls</a></p>
<h3>Create a poll</h3>
<form action="poll" method="post">
<input type="hidden" name="cmd" value="add">
<table class="blanks">
-<tr> <td>Title:</td> <td><input name="title"></td> </tr>
-<tr> <td>Start date:</td> <td><input name="starts"></td> </tr>
-<tr> <td>End date:</td> <td><input name="ends"></td> </tr>
-<tr> <td>Max votes/person:</td> <td><input name="votes"></td> </tr>
-<tr> <td>Description:</td> <td><textarea name="descr" wrap="soft" rows="5" cols="80"></textarea></td> </tr>
+<tr> <td>Title:</td> <td><input name="title" required="required"></td> </tr>
+<tr> <td>Start date:</td> <td><input name="starts" type="date" required="required"></td> </tr>
+<tr> <td>End date:</td> <td><input name="ends" type="date" required="required"></td> </tr>
+<tr> <td>Max votes/person:</td> <td><input name="votes" required="required" pattern="\\d+"></td> </tr>
+<tr> <td>Official:</td> <td><input type="checkbox" name="official"></td> </tr>
+<tr> <td>Description:</td> <td><textarea name="descr" wrap="soft" rows="5" cols="80" required="required"></textarea></td> </tr>
<tr> <td><input type="submit" value="Create"></td> </tr>
</table>
</form>
<% end
end %>
-<% @footer[] %>
\ No newline at end of file
+<% @footer[] %>