liquid_feedback_frontend
view 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 |
line source
1 local initiatives_selector = param.get("initiatives_selector", "table")
2 initiatives_selector:join("issue", nil, "issue.id = initiative.issue_id")
4 local issue = param.get("issue", "table")
6 local order_options = {}
8 if issue and issue.ranks_available then
9 order_options[#order_options+1] = {
10 name = "rank",
11 label = _"Rank",
12 order_by = "initiative.rank, initiative.admitted DESC, vote_ratio(initiative.positive_votes, initiative.negative_votes) DESC, initiative.id"
13 }
14 end
16 order_options[#order_options+1] = {
17 name = "potential_support",
18 label = _"Potential support",
19 order_by = "initiative.supporter_count::float / issue.population::float DESC, initiative.id"
20 }
22 order_options[#order_options+1] = {
23 name = "support",
24 label = _"Support",
25 order_by = "initiative.satisfied_supporter_count::float / issue.population::float DESC, initiative.id"
26 }
28 order_options[#order_options+1] = {
29 name = "newest",
30 label = _"Newest",
31 order_by = "initiative.created DESC, initiative.id"
32 }
34 order_options[#order_options+1] = {
35 name = "oldest",
36 label = _"Oldest",
37 order_by = "initiative.created, initiative.id"
38 }
40 local name = "initiative_list"
41 if issue then
42 name = "issue_" .. tostring(issue.id) .. "_initiative_list"
43 end
45 ui.order{
46 name = name,
47 selector = initiatives_selector,
48 options = order_options,
49 content = function()
50 ui.paginate{
51 selector = initiatives_selector,
52 content = function()
53 local initiatives = initiatives_selector:exec()
54 local columns = {}
55 columns[#columns+1] = {
56 content = function(record)
57 if record.issue.accepted and record.issue.closed and record.issue.ranks_available then
58 ui.field.rank{ attr = { class = "rank" }, value = record.rank }
59 end
60 end
61 }
62 columns[#columns+1] = {
63 content = function(record)
64 if record.issue.accepted and record.issue.closed then
65 if record.issue.ranks_available then
66 if record.negative_votes and record.positive_votes then
67 local max_value = record.issue.voter_count
68 ui.bargraph{
69 max_value = max_value,
70 width = 100,
71 bars = {
72 { color = "#0a0", value = record.positive_votes },
73 { color = "#aaa", value = max_value - record.negative_votes - record.positive_votes },
74 { color = "#a00", value = record.negative_votes },
75 }
76 }
77 end
78 else
79 slot.put(_"Counting of votes")
80 end
81 else
82 local max_value = (record.issue.population or 0)
83 ui.bargraph{
84 max_value = max_value,
85 width = 100,
86 bars = {
87 { color = "#0a0", value = (record.satisfied_supporter_count or 0) },
88 { color = "#777", value = (record.supporter_count or 0) - (record.satisfied_supporter_count or 0) },
89 { color = "#ddd", value = max_value - (record.supporter_count or 0) },
90 }
91 }
92 end
93 end
94 }
95 columns[#columns+1] = {
96 content = function(record)
97 ui.link{
98 content = function()
99 local name
100 if record.name_highlighted then
101 name = encode.highlight(record.name_highlighted)
102 else
103 name = encode.html(record.name)
104 end
105 slot.put(name)
106 end,
107 module = "initiative",
108 view = "show",
109 id = record.id
110 }
111 if record.issue.state == "new" then
112 ui.image{
113 static = "icons/16/new.png"
114 }
115 end
116 end
117 }
119 ui.list{
120 attr = { class = "initiatives" },
121 records = initiatives,
122 columns = columns
123 }
124 end
125 }
126 end
127 }