X-Git-Url: http://git.hcoop.net/bpt/portal.git/blobdiff_plain/93f77ca7c0fbfefe5eaf130c360cd1d112f40d52..49e613aeb7d8d989e43aa13bfa66c2b6cb0ac11f:/poll.mlt diff --git a/poll.mlt b/poll.mlt index ad8e152..735a201 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

    -
    + <% val choices = Poll.listChoicesWithMyVotes id; if #votes poll = 1 then %> @@ -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,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); editingPoll := SOME id; - %>

    Poll added!

    <% + %>

    Poll added!

    <% end elseif $"mod" <> "" then @@ -89,16 +97,17 @@ elseif $"mod" <> "" then val poll = Poll.lookupPoll (Web.stoi ($"mod")); Poll.requireCanModify poll %> -

    Modify poll

    +

    Modify poll

    -
    + "> - - - - - - +
    Title:
    Start date:
    End date:
    Max votes/person:
    Description:
    + + + + + +
    Title:
    Start date:
    End date:
    Max votes/person:
    Official: >
    Description:
    @@ -112,42 +121,43 @@ elseif $"mod" <> "" 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 - 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}; editingPoll := SOME (#id poll); - %>

    Poll record saved.

    <% + %>

    Poll record saved.

    <% end elseif $"del" <> "" then Group.requireGroupName "poll"; showNormal := false; val poll = Poll.lookupPoll (Web.stoi ($"del")) %> -

    Are you sure you want to delete poll <% Web.html (#title 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.deletePoll (Web.stoi ($"del2")) %> -

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

    +

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

    <% elseif $"addChoice" <> "" then val id = Web.stoi ($"addChoice"); editingPoll := SOME id; val descr = $"descr"; if descr = "" then - %>

    Your poll choice must have a description.

    <% + %>

    Your poll choice must have a description.

    <% else val id = Poll.addChoice (id, Web.stor ($"seq"), descr); - %>

    Choice added!

    <% + %>

    Choice added!

    <% end elseif $"modChoice" <> "" then @@ -157,11 +167,11 @@ elseif $"modChoice" <> "" then val poll = Poll.lookupPoll (#pol cho); Poll.requireCanModify poll %> -
    + - - - +
    Text:
    Sequence#:
    + +
    Text:
    Sequence#:
    @@ -174,10 +184,10 @@ elseif $"modChoice" <> "" then editingPoll := SOME (#id poll); val descr = $"descr"; if descr = "" then - %>

    Your poll choice must have a description.

    <% + %>

    Your poll choice must have a description.

    <% else Poll.modChoice {cho with seq = Web.stor ($"seq"), descr = descr}; - %>

    Choice saved!

    <% + %>

    Choice saved!

    <% end elseif $"delChoice" <> "" then @@ -186,7 +196,7 @@ elseif $"delChoice" <> "" then val poll = Poll.lookupPoll (#pol cho); Poll.requireCanModify poll; showNormal := false %> -

    Are you sure you want to delete choice "<% Web.html (#descr cho) %>"?

    +

    Are you sure you want to delete choice "<% Web.html (#descr cho) %>"?

    ">Yes, delete "<% Web.html (#descr cho) %>"! <% elseif $"delChoice2" <> "" then @@ -196,7 +206,7 @@ elseif $"delChoice" <> "" then Poll.requireCanModify poll; Poll.deleteChoice id; editingPoll := SOME (#id poll) %> -

    "<% Web.html (#descr cho) %>" deleted!

    +

    "<% Web.html (#descr cho) %>" deleted!

    <% elseif $"report" <> "" then showNormal := false; @@ -205,15 +215,27 @@ elseif $"delChoice" <> "" then val poll = Poll.lookupPoll id; val canModify = Poll.canModify poll %> -

    Vote Report

    +

    Vote Report

    - - - - - - - +

    Voters: +<% ref first = true; + foreach user in Poll.listPollVoters id do + if first then + first := false + else + %>, <% + end + %><% #name user %><% + end %>

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



    @@ -245,17 +267,20 @@ end %> val poll = Poll.lookupPoll id; val canModify = Poll.canModify poll %> - +
    <% if canModify then %><% end %> - - - - - - + + + + + + +
    Edit poll data
    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 Poll.takingVotes poll then %>(Vote!)<% end %>

    +

    Choices<% if Poll.takingVotes poll then %>(Vote!)<% end %>

    + +

    <% Poll.countVoters (#id poll) %> people have voted.

    <% if Poll.takingVotes poll then %> @@ -272,7 +297,6 @@ end %> <% end %>
    -Vote Report <% else foreach cho in Poll.listChoices id do %>
  • <% Web.html (#descr cho) %> @@ -284,35 +308,54 @@ foreach cho in Poll.listChoices id do %> <% end end %> +Vote Report + <% if canModify then %>


    -

    Add a new choice

    +

    Add a new choice

    -
    + - - - +
    Text:
    Sequence#:
    + +
    Text:
    Sequence#:
    <% end %> <% | NONE => -if showNormal then %> +if showNormal then + +val mlen = Poll.membershipLength (Init.getUserId ()) %> -Show all polls
    +

    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.

    -

    Create a poll

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

    Current polls

    -
    +<% foreach pol in polls do %> +
  • <% Web.html (#title pol) %> +<% if Poll.takingVotes pol then %>[VOTE]<% end %> +(<% Web.html (#starts pol) %> to <% Web.html (#ends pol) %>)
  • +<% end +end %> + +

    Show all polls

    + +

    Create a poll

    + + - - - - - - +
    Title:
    Start date:
    End date:
    Max votes/person:
    Description:
    + + + + + +
    Title:
    Start date:
    End date:
    Max votes/person:
    Official:
    Description: