liquid_feedback_frontend
annotate app/main/initiative/_list.lua @ 9:0ee1e0c42d4c
Version beta5
Minor security fix: Added missing security filter for admin section. Reading of member listing including login names was possible for all users. Write access has not been possible though.
Changing of name and login is possible while a history of these changes is written and accessible by all users.
Statistics shown in area list
Trimming of user input also converts multiple whitespaces to single space character.
Minor security fix: Added missing security filter for admin section. Reading of member listing including login names was possible for all users. Write access has not been possible though.
Changing of name and login is possible while a history of these changes is written and accessible by all users.
Statistics shown in area list
Trimming of user input also converts multiple whitespaces to single space character.
author | bsw |
---|---|
date | Mon Jan 04 12:00:00 2010 +0100 (2010-01-04) |
parents | afd9f769c7ae |
children | 72c5e0ee7c98 |
rev | line source |
---|---|
bsw/jbe@0 | 1 local initiatives_selector = param.get("initiatives_selector", "table") |
bsw/jbe@0 | 2 initiatives_selector:join("issue", nil, "issue.id = initiative.issue_id") |
bsw/jbe@0 | 3 |
bsw/jbe@0 | 4 local issue = param.get("issue", "table") |
bsw/jbe@0 | 5 |
bsw/jbe@0 | 6 local order_options = {} |
bsw/jbe@0 | 7 |
bsw/jbe@0 | 8 if issue and issue.ranks_available then |
bsw/jbe@0 | 9 order_options[#order_options+1] = { |
bsw/jbe@0 | 10 name = "rank", |
bsw/jbe@0 | 11 label = _"Rank", |
bsw/jbe@5 | 12 order_by = "initiative.rank, initiative.admitted DESC, vote_ratio(initiative.positive_votes, initiative.negative_votes) DESC, initiative.id" |
bsw/jbe@0 | 13 } |
bsw/jbe@0 | 14 end |
bsw/jbe@0 | 15 |
bsw/jbe@0 | 16 order_options[#order_options+1] = { |
bsw/jbe@5 | 17 name = "potential_support", |
bsw/jbe@5 | 18 label = _"Potential support", |
bsw/jbe@5 | 19 order_by = "initiative.supporter_count::float / issue.population::float DESC, initiative.id" |
bsw/jbe@5 | 20 } |
bsw/jbe@5 | 21 |
bsw/jbe@5 | 22 order_options[#order_options+1] = { |
bsw/jbe@0 | 23 name = "support", |
bsw/jbe@0 | 24 label = _"Support", |
bsw/jbe@5 | 25 order_by = "initiative.satisfied_supporter_count::float / issue.population::float DESC, initiative.id" |
bsw/jbe@0 | 26 } |
bsw/jbe@0 | 27 |
bsw/jbe@0 | 28 order_options[#order_options+1] = { |
bsw/jbe@0 | 29 name = "newest", |
bsw/jbe@0 | 30 label = _"Newest", |
bsw/jbe@5 | 31 order_by = "initiative.created DESC, initiative.id" |
bsw/jbe@0 | 32 } |
bsw/jbe@0 | 33 |
bsw/jbe@0 | 34 order_options[#order_options+1] = { |
bsw/jbe@0 | 35 name = "oldest", |
bsw/jbe@0 | 36 label = _"Oldest", |
bsw/jbe@5 | 37 order_by = "initiative.created, initiative.id" |
bsw/jbe@0 | 38 } |
bsw/jbe@0 | 39 |
bsw/jbe@0 | 40 local name = "initiative_list" |
bsw/jbe@0 | 41 if issue then |
bsw/jbe@0 | 42 name = "issue_" .. tostring(issue.id) .. "_initiative_list" |
bsw/jbe@0 | 43 end |
bsw/jbe@0 | 44 |
bsw/jbe@0 | 45 ui.order{ |
bsw/jbe@0 | 46 name = name, |
bsw/jbe@0 | 47 selector = initiatives_selector, |
bsw/jbe@0 | 48 options = order_options, |
bsw/jbe@0 | 49 content = function() |
bsw/jbe@0 | 50 ui.paginate{ |
bsw/jbe@0 | 51 selector = initiatives_selector, |
bsw/jbe@0 | 52 content = function() |
bsw/jbe@0 | 53 local initiatives = initiatives_selector:exec() |
bsw/jbe@0 | 54 local columns = {} |
bsw@2 | 55 columns[#columns+1] = { |
bsw@2 | 56 content = function(record) |
bsw@2 | 57 if record.issue.accepted and record.issue.closed and record.issue.ranks_available then |
bsw@3 | 58 ui.field.rank{ attr = { class = "rank" }, value = record.rank } |
bsw@3 | 59 end |
bsw@3 | 60 end |
bsw@3 | 61 } |
bsw@3 | 62 columns[#columns+1] = { |
bsw@3 | 63 content = function(record) |
bsw/jbe@5 | 64 if record.issue.accepted and record.issue.closed then |
bsw/jbe@5 | 65 if record.issue.ranks_available then |
bsw/jbe@5 | 66 if record.negative_votes and record.positive_votes then |
bsw/jbe@5 | 67 local max_value = record.issue.voter_count |
bsw/jbe@5 | 68 ui.bargraph{ |
bsw/jbe@5 | 69 max_value = max_value, |
bsw/jbe@5 | 70 width = 100, |
bsw/jbe@5 | 71 bars = { |
bsw/jbe@5 | 72 { color = "#0a0", value = record.positive_votes }, |
bsw/jbe@5 | 73 { color = "#aaa", value = max_value - record.negative_votes - record.positive_votes }, |
bsw/jbe@5 | 74 { color = "#a00", value = record.negative_votes }, |
bsw/jbe@5 | 75 } |
bsw/jbe@0 | 76 } |
bsw/jbe@5 | 77 end |
bsw/jbe@5 | 78 else |
bsw/jbe@5 | 79 slot.put(_"Counting of votes") |
bsw/jbe@0 | 80 end |
bsw@2 | 81 else |
bsw/jbe@0 | 82 local max_value = (record.issue.population or 0) |
bsw/jbe@0 | 83 ui.bargraph{ |
bsw/jbe@0 | 84 max_value = max_value, |
bsw/jbe@4 | 85 width = 100, |
bsw/jbe@0 | 86 bars = { |
bsw@2 | 87 { color = "#0a0", value = (record.satisfied_supporter_count or 0) }, |
bsw/jbe@5 | 88 { color = "#777", value = (record.supporter_count or 0) - (record.satisfied_supporter_count or 0) }, |
bsw/jbe@0 | 89 { color = "#ddd", value = max_value - (record.supporter_count or 0) }, |
bsw/jbe@0 | 90 } |
bsw/jbe@0 | 91 } |
bsw/jbe@0 | 92 end |
bsw@2 | 93 end |
bsw@2 | 94 } |
bsw/jbe@0 | 95 columns[#columns+1] = { |
bsw/jbe@0 | 96 content = function(record) |
bsw/jbe@0 | 97 ui.link{ |
bsw/jbe@0 | 98 content = function() |
bsw@2 | 99 local name |
bsw@2 | 100 if record.name_highlighted then |
bsw@2 | 101 name = encode.highlight(record.name_highlighted) |
bsw@2 | 102 else |
bsw@2 | 103 name = encode.html(record.name) |
bsw@2 | 104 end |
bsw@2 | 105 slot.put(name) |
bsw/jbe@0 | 106 end, |
bsw/jbe@0 | 107 module = "initiative", |
bsw/jbe@0 | 108 view = "show", |
bsw/jbe@0 | 109 id = record.id |
bsw/jbe@0 | 110 } |
bsw@2 | 111 if record.issue.state == "new" then |
bsw@2 | 112 ui.image{ |
bsw@2 | 113 static = "icons/16/new.png" |
bsw@2 | 114 } |
bsw@2 | 115 end |
bsw/jbe@0 | 116 end |
bsw/jbe@0 | 117 } |
bsw/jbe@0 | 118 |
bsw/jbe@0 | 119 ui.list{ |
bsw/jbe@0 | 120 attr = { class = "initiatives" }, |
bsw/jbe@0 | 121 records = initiatives, |
bsw/jbe@0 | 122 columns = columns |
bsw/jbe@0 | 123 } |
bsw/jbe@0 | 124 end |
bsw/jbe@0 | 125 } |
bsw/jbe@0 | 126 end |
bsw/jbe@0 | 127 } |