liquid_feedback_frontend
diff 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 |
line diff
1.1 --- a/app/main/vote/_action/update.lua Tue Feb 02 00:31:06 2010 +0100 1.2 +++ b/app/main/vote/_action/update.lua Sat Feb 20 22:10:31 2010 +0100 1.3 @@ -10,38 +10,145 @@ 1.4 return false 1.5 end 1.6 1.7 -local direct_voter = DirectVoter:by_pk(issue.id, app.session.member_id) 1.8 +local move_up = param.get("move_up", atom.integer) 1.9 +local move_down = param.get("move_down", atom.integer) 1.10 + 1.11 +if not move_down and not move_up then 1.12 + local direct_voter = DirectVoter:by_pk(issue.id, app.session.member_id) 1.13 + 1.14 + if not direct_voter then 1.15 + direct_voter = DirectVoter:new() 1.16 + direct_voter.issue_id = issue.id 1.17 + direct_voter.member_id = app.session.member_id 1.18 + end 1.19 + 1.20 + direct_voter.autoreject = false 1.21 + direct_voter:save() 1.22 + 1.23 + local scoring = param.get("scoring") 1.24 1.25 -if not direct_voter then 1.26 - direct_voter = DirectVoter:new() 1.27 - direct_voter.issue_id = issue.id 1.28 - direct_voter.member_id = app.session.member_id 1.29 -end 1.30 + for initiative_id, grade in scoring:gmatch("([^:;]+):([^:;]+)") do 1.31 + local initiative_id = tonumber(initiative_id) 1.32 + local grade = tonumber(grade) 1.33 + local initiative = Initiative:by_id(initiative_id) 1.34 + if initiative.issue.id ~= issue.id then 1.35 + error("initiative from wrong issue") 1.36 + end 1.37 + local vote = Vote:by_pk(initiative_id, app.session.member.id) 1.38 + if not vote then 1.39 + vote = Vote:new() 1.40 + vote.issue_id = issue.id 1.41 + vote.initiative_id = initiative.id 1.42 + vote.member_id = app.session.member.id 1.43 + end 1.44 + vote.grade = grade 1.45 + vote:save() 1.46 + end 1.47 + 1.48 +else 1.49 + 1.50 + local tempvoting_string = param.get("scoring") 1.51 1.52 -direct_voter.autoreject = false 1.53 + local tempvotings = {} 1.54 + for match in tempvoting_string:gmatch("([^;]+)") do 1.55 + for initiative_id, grade in match:gmatch("([^:;]+):([^:;]+)") do 1.56 + tempvotings[tonumber(initiative_id)] = tonumber(grade) 1.57 + end 1.58 + end 1.59 + 1.60 + local current_initiative_id = move_up or move_down 1.61 1.62 -direct_voter:save() 1.63 + local current_grade = tempvotings[current_initiative_id] or 0 1.64 + local is_alone = true 1.65 + if current_grade == 0 then 1.66 + is_alone = false 1.67 + else 1.68 + for initiative_id, grade in pairs(tempvotings) do 1.69 + if current_initiative_id ~= initiative_id and grade == current_grade then 1.70 + is_alone = false 1.71 + break 1.72 + end 1.73 + end 1.74 + end 1.75 1.76 - 1.77 -local scoring = param.get("scoring") 1.78 + if move_up and current_grade >= 0 and is_alone then 1.79 + for initiative_id, grade in pairs(tempvotings) do 1.80 + if grade > current_grade then 1.81 + tempvotings[initiative_id] = grade - 1 1.82 + end 1.83 + end 1.84 1.85 -for initiative_id, grade in scoring:gmatch("([^:;]+):([^:;]+)") do 1.86 - local initiative_id = tonumber(initiative_id) 1.87 - local grade = tonumber(grade) 1.88 - local initiative = Initiative:by_id(initiative_id) 1.89 - if initiative.issue.id ~= issue.id then 1.90 - error("initiative from wrong issue") 1.91 + elseif move_up and current_grade >= 0 and not is_alone then 1.92 + for initiative_id, grade in pairs(tempvotings) do 1.93 + if grade > current_grade then 1.94 + tempvotings[initiative_id] = grade + 1 1.95 + end 1.96 + end 1.97 + tempvotings[current_initiative_id] = current_grade + 1 1.98 + 1.99 + elseif move_up and current_grade < 0 and is_alone then 1.100 + tempvotings[current_initiative_id] = current_grade + 1 1.101 + for initiative_id, grade in pairs(tempvotings) do 1.102 + if grade < current_grade then 1.103 + tempvotings[initiative_id] = grade + 1 1.104 + end 1.105 + end 1.106 + 1.107 + elseif move_up and current_grade < 0 and not is_alone then 1.108 + for initiative_id, grade in pairs(tempvotings) do 1.109 + if grade <= current_grade then 1.110 + tempvotings[initiative_id] = grade - 1 1.111 + end 1.112 + end 1.113 + tempvotings[current_initiative_id] = current_grade 1.114 + 1.115 + elseif move_down and current_grade <= 0 and is_alone then 1.116 + for initiative_id, grade in pairs(tempvotings) do 1.117 + if grade < current_grade then 1.118 + tempvotings[initiative_id] = grade + 1 1.119 + end 1.120 + end 1.121 + 1.122 + elseif move_down and current_grade <= 0 and not is_alone then 1.123 + for initiative_id, grade in pairs(tempvotings) do 1.124 + if grade < current_grade then 1.125 + tempvotings[initiative_id] = grade - 1 1.126 + end 1.127 + end 1.128 + tempvotings[current_initiative_id] = current_grade - 1 1.129 + 1.130 + elseif move_down and current_grade > 0 and is_alone then 1.131 + tempvotings[current_initiative_id] = current_grade - 1 1.132 + for initiative_id, grade in pairs(tempvotings) do 1.133 + if grade > current_grade then 1.134 + tempvotings[initiative_id] = grade - 1 1.135 + end 1.136 + end 1.137 + 1.138 + elseif move_down and current_grade > 0 and not is_alone then 1.139 + for initiative_id, grade in pairs(tempvotings) do 1.140 + if grade >= current_grade then 1.141 + tempvotings[initiative_id] = grade + 1 1.142 + end 1.143 + end 1.144 + tempvotings[current_initiative_id] = current_grade 1.145 + 1.146 end 1.147 - local vote = Vote:by_pk(initiative_id, app.session.member.id) 1.148 - if not vote then 1.149 - vote = Vote:new() 1.150 - vote.issue_id = issue.id 1.151 - vote.initiative_id = initiative.id 1.152 - vote.member_id = app.session.member.id 1.153 + 1.154 + local tempvotings_list = {} 1.155 + for key, val in pairs(tempvotings) do 1.156 + tempvotings_list[#tempvotings_list+1] = tostring(key) .. ":" .. tostring(val) 1.157 end 1.158 - vote.grade = grade 1.159 - vote:save() 1.160 + 1.161 + tempvoting_string = table.concat(tempvotings_list, ";") 1.162 + 1.163 + request.redirect{ 1.164 + module = "vote", 1.165 + view = "list", 1.166 + params = { 1.167 + issue_id = issue.id, 1.168 + scoring = tempvoting_string 1.169 + } 1.170 + } 1.171 + 1.172 end 1.173 - 1.174 -trace.debug(scoring) 1.175 -