X-Git-Url: https://git.hcoop.net/bpt/portal.git/blobdiff_plain/972c70b709b8a055d826343be34619d2470ca394..6aa0cd21ab8b74949d95d375e22dae72a9f35b8c:/poll.mlt diff --git a/poll.mlt b/poll.mlt index 4b7d968..200c96a 100644 --- a/poll.mlt +++ b/poll.mlt @@ -27,9 +27,13 @@ elseif $"vote" <> "" then 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) %> +<% 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

@@ -47,7 +51,8 @@ foreach (you, cho) in choices do %>
-<% elseif $"vote2" <> "" then +<% end +elseif $"vote2" <> "" then val id = Web.stoi ($"vote2"); val poll = Poll.lookupPoll id; editingPoll := SOME id; @@ -56,7 +61,9 @@ foreach (you, cho) in choices do %> [""] => [] | v => map Web.stoi v; - if length votes > #votes poll then + 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!

<% @@ -70,6 +77,7 @@ 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.

<% elseif not pollAdmin and not (Poll.dateGeNow starts) then @@ -79,7 +87,7 @@ elseif $"cmd" = "add" then elseif votes <= 0 then %>

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!

<% end @@ -95,9 +103,11 @@ elseif $"mod" <> "" then "> + +
Title:
Ready? >
Start date:
End date:
Max votes/person:
Official: >
Description:
@@ -112,7 +122,11 @@ elseif $"mod" <> "" then 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 + %>

You can't modify this poll anymore, because voting is already open.

<% + elseif title = "" then %>

Your poll must have a title.

<% elseif not pollAdmin and not (Poll.dateGeNow starts) then %>

That start date is in the past!

<% @@ -121,21 +135,22 @@ elseif $"mod" <> "" then elseif votes <= 0 then %>

You must specify a positive number of votes per person.

<% 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); %>

Poll record saved.

<% 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!

@@ -143,7 +158,10 @@ elseif $"del" <> "" then 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 + %>

You can't modify this poll anymore, because voting is already open.

<% + elseif descr = "" then %>

Your poll choice must have a description.

<% else val id = Poll.addChoice (id, Web.stor ($"seq"), descr); @@ -224,6 +242,7 @@ elseif $"delChoice" <> "" then 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) %> @@ -263,6 +282,7 @@ end %> 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) %> @@ -300,6 +320,8 @@ end %> <% if canModify then %>


+

Delete this poll

+

Add a new choice

@@ -315,7 +337,11 @@ end %> <% | NONE => if showNormal then -val polls = Poll.listCurrentPolls (); +val mlen = Poll.membershipLength (Init.getUserId ()) %> + +

You have been an HCoop member for <% mlen %> days, so you are<% if mlen < Poll.votingMembershipRequirement then %> not<% end %> eligible to vote in official polls.

+ +<% val polls = Poll.listCurrentPolls (); switch polls of _::_ => %>

Current polls

@@ -338,6 +364,7 @@ end %> Start date: End date: Max votes/person: + Official: Description: