liquid_feedback_frontend
view app/main/api/initiative.lua @ 75:733f65c0c0a0
Bugfixes, feature enhancements, code-cleanup, and major work on API
Details:
- API
-- Allow relation name to be passed to helper function util.autoapi{...}
-- Added area API
-- Bugfixes in API
--- Correctly return initiatives (bug #162)
--- Correctly process "id" parameter for initiative API
--- Bugfix related to "state" parameter (bug #165)
--- Changed constant "discussion" to "accepted" (in model/issue.lua, used by API)
--- Fixed JSON encoding in auto_api (bug #181)
--- Ignore list filter "voted" in case of public access
--- Enable access to API without session
- Work on RSS feed (incomplete yet)
- Other bugfixes
-- Handle empty browser identification string
-- Handle invalid date in member/update.lua (bugs #24 #109 #115 #136)
-- Better handle errors while converting uploaded images. (bug #79 +5 duplicates)
-- Don't display revoked initiatives in list of new drafts (bug #134)
-- Fixed syntax error in app/main/member/_action/update_name.lua throwing unexpected error, when new name was too short
-- Do not display refresh support button for revoked initiatives
-- Repaired issue search (bug #150)
-- Fixed typos in german translation files
--- "initi(i)erte"
--- "Er(g)eignisse" (bug #161)
- Code cleanup
-- Removed deprecated motd files locale/motd/de.txt and locale/motd/de_public.txt
-- Removed redundant code in app/main/index/_updated_drafts.lua
- New features and (optical) enhancements
-- Support change of notify email; notification of not approved address added to start page
-- Settings dialog splitted into single pages
-- Mark deactivated members
-- Calendar for birthday selection in profile
-- Policy list public readable when public access is enabled
Details:
- API
-- Allow relation name to be passed to helper function util.autoapi{...}
-- Added area API
-- Bugfixes in API
--- Correctly return initiatives (bug #162)
--- Correctly process "id" parameter for initiative API
--- Bugfix related to "state" parameter (bug #165)
--- Changed constant "discussion" to "accepted" (in model/issue.lua, used by API)
--- Fixed JSON encoding in auto_api (bug #181)
--- Ignore list filter "voted" in case of public access
--- Enable access to API without session
- Work on RSS feed (incomplete yet)
- Other bugfixes
-- Handle empty browser identification string
-- Handle invalid date in member/update.lua (bugs #24 #109 #115 #136)
-- Better handle errors while converting uploaded images. (bug #79 +5 duplicates)
-- Don't display revoked initiatives in list of new drafts (bug #134)
-- Fixed syntax error in app/main/member/_action/update_name.lua throwing unexpected error, when new name was too short
-- Do not display refresh support button for revoked initiatives
-- Repaired issue search (bug #150)
-- Fixed typos in german translation files
--- "initi(i)erte"
--- "Er(g)eignisse" (bug #161)
- Code cleanup
-- Removed deprecated motd files locale/motd/de.txt and locale/motd/de_public.txt
-- Removed redundant code in app/main/index/_updated_drafts.lua
- New features and (optical) enhancements
-- Support change of notify email; notification of not approved address added to start page
-- Settings dialog splitted into single pages
-- Mark deactivated members
-- Calendar for birthday selection in profile
-- Policy list public readable when public access is enabled
author | bsw |
---|---|
date | Thu Jul 08 18:44:02 2010 +0200 (2010-07-08) |
parents | 0849be391140 |
children | 134fce4bede3 |
line source
1 local id = param.get("id")
2 local min_id = param.get("min_id")
3 local max_id = param.get("max_id")
4 local area_id = param.get("area_id", atom.integer)
5 local issue_id = param.get("issue_id", atom.integer)
6 local policy_id = param.get("policy_id", atom.integer)
7 local state = param.get("state")
8 local agreed = param.get("agreed")
9 local rank = param.get("rank")
10 local search = param.get("search")
11 local search_context = param.get("search_context") or "full"
12 local limit = param.get("limit", atom.integer)
13 local order = param.get("order")
15 local initiatives_selector = Initiative:new_selector()
16 :join("issue", nil, "issue.id = initiative.issue_id")
17 :join("area", nil, "area.id = issue.area_id")
18 :join("policy", nil, "policy.id = issue.policy_id")
20 if id then
21 initiatives_selector:add_where{"initiative.id = ?", id}
22 end
24 if min_id then
25 initiatives_selector:add_where{"initiative.id >= ?", min_id}
26 end
28 if max_id then
29 initiatives_selector:add_where{"initiative.id <= ?", max_id}
30 end
32 if area_id then
33 initiatives_selector:add_where{"area.id = ?", area_id}
34 end
36 if issue_id then
37 initiatives_selector:add_where{"issue.id = ?", issue_id}
38 end
40 if policy_id then
41 initiatives_selector:add_where{"policy.id = ?", policy_id}
42 end
44 if state then
45 Issue:modify_selector_for_state(initiatives_selector, state)
46 end
48 if agreed then
49 initiatives_selector:add_where("initiative.agreed")
50 end
52 if rank then
53 initiatives_selector:add_where{ "initiative.rank = ?", rank }
54 end
56 if search then
57 if search_context == "full" then
58 elseif search_context == "title" then
59 end
60 end
62 if order == "supporter_count" then
63 initiatives_selector:add_order_by("initiative.supporter_count")
64 end
66 initiatives_selector:add_order_by("initiative.id")
68 if limit then
69 initiatives_selector:limit(limit)
70 end
72 local api_engine = param.get("api_engine") or "xml"
74 local function format_timestamp(timestamp)
75 if timestamp then
76 return format.timestamp(timestamp)
77 else
78 return ""
79 end
80 end
82 local fields = {
84 { name = "area_id", field = "area.id" },
85 { name = "area_name", field = "area.name" },
86 { name = "issue_id", field = "issue.id" },
87 {
88 name = "issue_state",
89 func = function(record)
90 return record.issue.state
91 end
92 },
93 {
94 name = "issue_created",
95 field = "issue.created",
96 func = function(record)
97 return format_timestamp(record.issue_created)
98 end
99 },
100 {
101 name = "issue_accepted",
102 field = "issue.accepted",
103 func = function(record)
104 return format_timestamp(record.issue_accepted)
105 end
106 },
107 {
108 name = "issue_half_frozen",
109 field = "issue.half_frozen",
110 func = function(record)
111 return format_timestamp(record.issue_half_frozen)
112 end
113 },
114 {
115 name = "issue_fully_frozen",
116 field = "issue.fully_frozen",
117 func = function(record)
118 return format_timestamp(record.issue_fully_frozen)
119 end
120 },
121 {
122 name = "issue_closed",
123 field = "issue.closed",
124 func = function(record)
125 return format_timestamp(record.issue_closed)
126 end
127 },
128 { name = "issue_admission_time", field = "issue.admission_time" },
129 { name = "issue_discussion_time", field = "issue.discussion_time" },
130 { name = "issue_verification_time", field = "issue.verification_time" },
131 { name = "issue_voting_time", field = "issue.voting_time" },
132 { name = "issue_ranks_available", field = "issue.ranks_available" },
134 { name = "policy_issue_quorum_num", field = "policy.issue_quorum_num" },
135 { name = "policy_issue_quorum_den", field = "policy.issue_quorum_den" },
136 { name = "policy_initiative_quorum_num",
137 field = "policy.initiative_quorum_num" },
138 { name = "policy_initiative_quorum_den",
139 field = "policy.initiative_quorum_den" },
140 { name = "policy_majority_num", field = "policy.majority_num" },
141 { name = "policy_majority_den", field = "policy.majority_den" },
142 { name = "policy_majority_strict", field = "policy.majority_strict" },
143 { name = "id", field = "initiative.id" },
144 { name = "name", field = "initiative.name" },
145 { name = "discussion_url", field = "initiative.discussion_url" },
146 {
147 name = "created",
148 field = "initiative.created",
149 func = function(record)
150 return format.timestamp(record.created)
151 end
152 },
153 { name = "revoked", field = "initiative.revoked" },
154 { name = "suggested_initiative_id", field = "initiative.suggested_initiative_id" },
155 { name = "admitted", field = "initiative.admitted" },
156 { name = "issue_population", field = "issue.population" },
157 { name = "supporter_count", field = "initiative.supporter_count" },
158 { name = "informed_supporter_count", field = "initiative.informed_supporter_count" },
159 { name = "satisfied_supporter_count", field = "initiative.satisfied_supporter_count" },
160 { name = "satisfied_informed_supporter_count",
161 field = "initiative.satisfied_informed_supporter_count" },
162 { name = "issue_vote_now", field = "issue.vote_now" },
163 { name = "issue_vote_later", field = "issue.vote_later" },
164 { name = "issue_voter_count", field = "issue.voter_count" },
165 { name = "positive_votes", field = "initiative.positive_votes" },
166 { name = "negative_votes", field = "initiative.negative_votes" },
167 { name = "agreed", field = "initiative.agreed" },
168 { name = "rank", field = "initiative.rank" },
169 {
170 name = "current_draft_created",
171 func = function(record)
172 return format.timestamp(record.current_draft.created)
173 end
174 },
175 {
176 name = "current_draft_formatting_engine",
177 func = function(record)
178 return record.current_draft.formatting_engine
179 end
180 },
181 {
182 name = "current_draft_content",
183 func = function(record)
184 return record.current_draft.content
185 end
186 }
187 }
189 util.autoapi{
190 relation_name = "initiative",
191 selector = initiatives_selector,
192 fields = fields,
193 api_engine = api_engine
194 }