liquid_feedback_frontend
annotate app/main/vote/_action/update.lua @ 19:00d1004545f1
Dynamic interface using XMLHttpRequests, and many other changes
Bugfixes:
- Only allow voting on admitted initiatives
- Repaired issue search
- Don't display delegations for closed issues on member page
- Don't show revoke link in initiative, when issue is already half_frozen
- Localization for voting JavaScript
- Display author of suggestions
Disclosure of voting data after voting is finished:
- Possibility to inspect every ballot including preferences
- Show number of voters preferring one initiative to another initiative
Interface behaviour changes:
- Reversed default order of drafts
- Default order of suggestions changed
- Show new drafts of initiatives only once per day in timeline
Accessibility:
- Barrier-free voting implemented
- POST links are now accessible without JavaScript
- Changed gray for unsatisfied supporters in bar graph to a lighter gray
Other interface improvements:
- Optical enhancements
- Dynamic interface using XMLHttpRequests
- Show usage terms in about section
- Show own membership in area listing
- Show uninformed supporters greyed out and marked with yellow question mark
- Warning box in non-admitted initiatives
- When voted, don't display voting notice and change label of voting link
- Show object counts in more tabulator heads
- Enlarged member statement input field
Miscellaneous:
- Code cleanup
- Added README file containing installation instructions
- Use new WebMCP function ui.filters{...} instead of own ui.filter and ui.order functions
Bugfixes:
- Only allow voting on admitted initiatives
- Repaired issue search
- Don't display delegations for closed issues on member page
- Don't show revoke link in initiative, when issue is already half_frozen
- Localization for voting JavaScript
- Display author of suggestions
Disclosure of voting data after voting is finished:
- Possibility to inspect every ballot including preferences
- Show number of voters preferring one initiative to another initiative
Interface behaviour changes:
- Reversed default order of drafts
- Default order of suggestions changed
- Show new drafts of initiatives only once per day in timeline
Accessibility:
- Barrier-free voting implemented
- POST links are now accessible without JavaScript
- Changed gray for unsatisfied supporters in bar graph to a lighter gray
Other interface improvements:
- Optical enhancements
- Dynamic interface using XMLHttpRequests
- Show usage terms in about section
- Show own membership in area listing
- Show uninformed supporters greyed out and marked with yellow question mark
- Warning box in non-admitted initiatives
- When voted, don't display voting notice and change label of voting link
- Show object counts in more tabulator heads
- Enlarged member statement input field
Miscellaneous:
- Code cleanup
- Added README file containing installation instructions
- Use new WebMCP function ui.filters{...} instead of own ui.filter and ui.order functions
| author | bsw/jbe |
|---|---|
| date | Sat Feb 20 22:10:31 2010 +0100 (2010-02-20) |
| parents | afd9f769c7ae |
| children | 3036f2732b83 |
| rev | line source |
|---|---|
| bsw/jbe@5 | 1 local issue = Issue:new_selector():add_where{ "id = ?", param.get("issue_id", atom.integer) }:for_share():single_object_mode():exec() |
| bsw/jbe@5 | 2 |
| bsw/jbe@5 | 3 if issue.closed then |
| bsw/jbe@5 | 4 slot.put_into("error", _"This issue is already closed.") |
| bsw/jbe@5 | 5 return false |
| bsw/jbe@5 | 6 end |
| bsw/jbe@5 | 7 |
| bsw/jbe@5 | 8 if issue.state ~= "voting" then |
| bsw/jbe@5 | 9 slot.put_into("error", _"Voting has not started yet.") |
| bsw/jbe@5 | 10 return false |
| bsw/jbe@5 | 11 end |
| bsw/jbe@5 | 12 |
| bsw/jbe@19 | 13 local move_up = param.get("move_up", atom.integer) |
| bsw/jbe@19 | 14 local move_down = param.get("move_down", atom.integer) |
| bsw/jbe@19 | 15 |
| bsw/jbe@19 | 16 if not move_down and not move_up then |
| bsw/jbe@19 | 17 local direct_voter = DirectVoter:by_pk(issue.id, app.session.member_id) |
| bsw/jbe@19 | 18 |
| bsw/jbe@19 | 19 if not direct_voter then |
| bsw/jbe@19 | 20 direct_voter = DirectVoter:new() |
| bsw/jbe@19 | 21 direct_voter.issue_id = issue.id |
| bsw/jbe@19 | 22 direct_voter.member_id = app.session.member_id |
| bsw/jbe@19 | 23 end |
| bsw/jbe@19 | 24 |
| bsw/jbe@19 | 25 direct_voter.autoreject = false |
| bsw/jbe@19 | 26 direct_voter:save() |
| bsw/jbe@19 | 27 |
| bsw/jbe@19 | 28 local scoring = param.get("scoring") |
| bsw/jbe@5 | 29 |
| bsw/jbe@19 | 30 for initiative_id, grade in scoring:gmatch("([^:;]+):([^:;]+)") do |
| bsw/jbe@19 | 31 local initiative_id = tonumber(initiative_id) |
| bsw/jbe@19 | 32 local grade = tonumber(grade) |
| bsw/jbe@19 | 33 local initiative = Initiative:by_id(initiative_id) |
| bsw/jbe@19 | 34 if initiative.issue.id ~= issue.id then |
| bsw/jbe@19 | 35 error("initiative from wrong issue") |
| bsw/jbe@19 | 36 end |
| bsw/jbe@19 | 37 local vote = Vote:by_pk(initiative_id, app.session.member.id) |
| bsw/jbe@19 | 38 if not vote then |
| bsw/jbe@19 | 39 vote = Vote:new() |
| bsw/jbe@19 | 40 vote.issue_id = issue.id |
| bsw/jbe@19 | 41 vote.initiative_id = initiative.id |
| bsw/jbe@19 | 42 vote.member_id = app.session.member.id |
| bsw/jbe@19 | 43 end |
| bsw/jbe@19 | 44 vote.grade = grade |
| bsw/jbe@19 | 45 vote:save() |
| bsw/jbe@19 | 46 end |
| bsw/jbe@19 | 47 |
| bsw/jbe@19 | 48 else |
| bsw/jbe@19 | 49 |
| bsw/jbe@19 | 50 local tempvoting_string = param.get("scoring") |
| bsw/jbe@5 | 51 |
| bsw/jbe@19 | 52 local tempvotings = {} |
| bsw/jbe@19 | 53 for match in tempvoting_string:gmatch("([^;]+)") do |
| bsw/jbe@19 | 54 for initiative_id, grade in match:gmatch("([^:;]+):([^:;]+)") do |
| bsw/jbe@19 | 55 tempvotings[tonumber(initiative_id)] = tonumber(grade) |
| bsw/jbe@19 | 56 end |
| bsw/jbe@19 | 57 end |
| bsw/jbe@19 | 58 |
| bsw/jbe@19 | 59 local current_initiative_id = move_up or move_down |
| bsw/jbe@5 | 60 |
| bsw/jbe@19 | 61 local current_grade = tempvotings[current_initiative_id] or 0 |
| bsw/jbe@19 | 62 local is_alone = true |
| bsw/jbe@19 | 63 if current_grade == 0 then |
| bsw/jbe@19 | 64 is_alone = false |
| bsw/jbe@19 | 65 else |
| bsw/jbe@19 | 66 for initiative_id, grade in pairs(tempvotings) do |
| bsw/jbe@19 | 67 if current_initiative_id ~= initiative_id and grade == current_grade then |
| bsw/jbe@19 | 68 is_alone = false |
| bsw/jbe@19 | 69 break |
| bsw/jbe@19 | 70 end |
| bsw/jbe@19 | 71 end |
| bsw/jbe@19 | 72 end |
| bsw/jbe@5 | 73 |
| bsw/jbe@19 | 74 if move_up and current_grade >= 0 and is_alone then |
| bsw/jbe@19 | 75 for initiative_id, grade in pairs(tempvotings) do |
| bsw/jbe@19 | 76 if grade > current_grade then |
| bsw/jbe@19 | 77 tempvotings[initiative_id] = grade - 1 |
| bsw/jbe@19 | 78 end |
| bsw/jbe@19 | 79 end |
| bsw/jbe@5 | 80 |
| bsw/jbe@19 | 81 elseif move_up and current_grade >= 0 and not is_alone then |
| bsw/jbe@19 | 82 for initiative_id, grade in pairs(tempvotings) do |
| bsw/jbe@19 | 83 if grade > current_grade then |
| bsw/jbe@19 | 84 tempvotings[initiative_id] = grade + 1 |
| bsw/jbe@19 | 85 end |
| bsw/jbe@19 | 86 end |
| bsw/jbe@19 | 87 tempvotings[current_initiative_id] = current_grade + 1 |
| bsw/jbe@19 | 88 |
| bsw/jbe@19 | 89 elseif move_up and current_grade < 0 and is_alone then |
| bsw/jbe@19 | 90 tempvotings[current_initiative_id] = current_grade + 1 |
| bsw/jbe@19 | 91 for initiative_id, grade in pairs(tempvotings) do |
| bsw/jbe@19 | 92 if grade < current_grade then |
| bsw/jbe@19 | 93 tempvotings[initiative_id] = grade + 1 |
| bsw/jbe@19 | 94 end |
| bsw/jbe@19 | 95 end |
| bsw/jbe@19 | 96 |
| bsw/jbe@19 | 97 elseif move_up and current_grade < 0 and not is_alone then |
| bsw/jbe@19 | 98 for initiative_id, grade in pairs(tempvotings) do |
| bsw/jbe@19 | 99 if grade <= current_grade then |
| bsw/jbe@19 | 100 tempvotings[initiative_id] = grade - 1 |
| bsw/jbe@19 | 101 end |
| bsw/jbe@19 | 102 end |
| bsw/jbe@19 | 103 tempvotings[current_initiative_id] = current_grade |
| bsw/jbe@19 | 104 |
| bsw/jbe@19 | 105 elseif move_down and current_grade <= 0 and is_alone then |
| bsw/jbe@19 | 106 for initiative_id, grade in pairs(tempvotings) do |
| bsw/jbe@19 | 107 if grade < current_grade then |
| bsw/jbe@19 | 108 tempvotings[initiative_id] = grade + 1 |
| bsw/jbe@19 | 109 end |
| bsw/jbe@19 | 110 end |
| bsw/jbe@19 | 111 |
| bsw/jbe@19 | 112 elseif move_down and current_grade <= 0 and not is_alone then |
| bsw/jbe@19 | 113 for initiative_id, grade in pairs(tempvotings) do |
| bsw/jbe@19 | 114 if grade < current_grade then |
| bsw/jbe@19 | 115 tempvotings[initiative_id] = grade - 1 |
| bsw/jbe@19 | 116 end |
| bsw/jbe@19 | 117 end |
| bsw/jbe@19 | 118 tempvotings[current_initiative_id] = current_grade - 1 |
| bsw/jbe@19 | 119 |
| bsw/jbe@19 | 120 elseif move_down and current_grade > 0 and is_alone then |
| bsw/jbe@19 | 121 tempvotings[current_initiative_id] = current_grade - 1 |
| bsw/jbe@19 | 122 for initiative_id, grade in pairs(tempvotings) do |
| bsw/jbe@19 | 123 if grade > current_grade then |
| bsw/jbe@19 | 124 tempvotings[initiative_id] = grade - 1 |
| bsw/jbe@19 | 125 end |
| bsw/jbe@19 | 126 end |
| bsw/jbe@19 | 127 |
| bsw/jbe@19 | 128 elseif move_down and current_grade > 0 and not is_alone then |
| bsw/jbe@19 | 129 for initiative_id, grade in pairs(tempvotings) do |
| bsw/jbe@19 | 130 if grade >= current_grade then |
| bsw/jbe@19 | 131 tempvotings[initiative_id] = grade + 1 |
| bsw/jbe@19 | 132 end |
| bsw/jbe@19 | 133 end |
| bsw/jbe@19 | 134 tempvotings[current_initiative_id] = current_grade |
| bsw/jbe@19 | 135 |
| bsw/jbe@5 | 136 end |
| bsw/jbe@19 | 137 |
| bsw/jbe@19 | 138 local tempvotings_list = {} |
| bsw/jbe@19 | 139 for key, val in pairs(tempvotings) do |
| bsw/jbe@19 | 140 tempvotings_list[#tempvotings_list+1] = tostring(key) .. ":" .. tostring(val) |
| bsw/jbe@5 | 141 end |
| bsw/jbe@19 | 142 |
| bsw/jbe@19 | 143 tempvoting_string = table.concat(tempvotings_list, ";") |
| bsw/jbe@19 | 144 |
| bsw/jbe@19 | 145 request.redirect{ |
| bsw/jbe@19 | 146 module = "vote", |
| bsw/jbe@19 | 147 view = "list", |
| bsw/jbe@19 | 148 params = { |
| bsw/jbe@19 | 149 issue_id = issue.id, |
| bsw/jbe@19 | 150 scoring = tempvoting_string |
| bsw/jbe@19 | 151 } |
| bsw/jbe@19 | 152 } |
| bsw/jbe@19 | 153 |
| bsw/jbe@5 | 154 end |