liquid_feedback_frontend
annotate 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 |
rev | line source |
---|---|
bsw@75 | 1 local id = param.get("id") |
bsw@51 | 2 local min_id = param.get("min_id") |
bsw@51 | 3 local max_id = param.get("max_id") |
bsw@51 | 4 local area_id = param.get("area_id", atom.integer) |
bsw@51 | 5 local issue_id = param.get("issue_id", atom.integer) |
bsw@51 | 6 local policy_id = param.get("policy_id", atom.integer) |
bsw@51 | 7 local state = param.get("state") |
bsw@51 | 8 local agreed = param.get("agreed") |
bsw@51 | 9 local rank = param.get("rank") |
bsw@51 | 10 local search = param.get("search") |
bsw@51 | 11 local search_context = param.get("search_context") or "full" |
bsw@51 | 12 local limit = param.get("limit", atom.integer) |
bsw@51 | 13 local order = param.get("order") |
bsw@51 | 14 |
bsw@51 | 15 local initiatives_selector = Initiative:new_selector() |
bsw@75 | 16 :join("issue", nil, "issue.id = initiative.issue_id") |
bsw@51 | 17 :join("area", nil, "area.id = issue.area_id") |
bsw@51 | 18 :join("policy", nil, "policy.id = issue.policy_id") |
bsw@51 | 19 |
bsw@51 | 20 if id then |
bsw@51 | 21 initiatives_selector:add_where{"initiative.id = ?", id} |
bsw@51 | 22 end |
bsw@51 | 23 |
bsw@51 | 24 if min_id then |
bsw@51 | 25 initiatives_selector:add_where{"initiative.id >= ?", min_id} |
bsw@51 | 26 end |
bsw@51 | 27 |
bsw@51 | 28 if max_id then |
bsw@51 | 29 initiatives_selector:add_where{"initiative.id <= ?", max_id} |
bsw@51 | 30 end |
bsw@51 | 31 |
bsw@51 | 32 if area_id then |
bsw@51 | 33 initiatives_selector:add_where{"area.id = ?", area_id} |
bsw@51 | 34 end |
bsw@51 | 35 |
bsw@51 | 36 if issue_id then |
bsw@51 | 37 initiatives_selector:add_where{"issue.id = ?", issue_id} |
bsw@51 | 38 end |
bsw@51 | 39 |
bsw@51 | 40 if policy_id then |
bsw@51 | 41 initiatives_selector:add_where{"policy.id = ?", policy_id} |
bsw@51 | 42 end |
bsw@51 | 43 |
bsw@51 | 44 if state then |
bsw@75 | 45 Issue:modify_selector_for_state(initiatives_selector, state) |
bsw@51 | 46 end |
bsw@51 | 47 |
bsw@51 | 48 if agreed then |
bsw@51 | 49 initiatives_selector:add_where("initiative.agreed") |
bsw@51 | 50 end |
bsw@51 | 51 |
bsw@51 | 52 if rank then |
bsw@51 | 53 initiatives_selector:add_where{ "initiative.rank = ?", rank } |
bsw@51 | 54 end |
bsw@51 | 55 |
bsw@51 | 56 if search then |
bsw@51 | 57 if search_context == "full" then |
bsw@51 | 58 elseif search_context == "title" then |
bsw@51 | 59 end |
bsw@51 | 60 end |
bsw@51 | 61 |
bsw@51 | 62 if order == "supporter_count" then |
bsw@51 | 63 initiatives_selector:add_order_by("initiative.supporter_count") |
bsw@51 | 64 end |
bsw@51 | 65 |
bsw@51 | 66 initiatives_selector:add_order_by("initiative.id") |
bsw@51 | 67 |
bsw@51 | 68 if limit then |
bsw@51 | 69 initiatives_selector:limit(limit) |
bsw@51 | 70 end |
bsw@51 | 71 |
bsw@51 | 72 local api_engine = param.get("api_engine") or "xml" |
bsw@51 | 73 |
bsw@51 | 74 local function format_timestamp(timestamp) |
bsw@51 | 75 if timestamp then |
bsw@51 | 76 return format.timestamp(timestamp) |
bsw@51 | 77 else |
bsw@51 | 78 return "" |
bsw@51 | 79 end |
bsw@51 | 80 end |
bsw@51 | 81 |
bsw@51 | 82 local fields = { |
bsw@51 | 83 |
bsw@51 | 84 { name = "area_id", field = "area.id" }, |
bsw@51 | 85 { name = "area_name", field = "area.name" }, |
bsw@51 | 86 { name = "issue_id", field = "issue.id" }, |
bsw@51 | 87 { |
bsw@51 | 88 name = "issue_state", |
bsw@51 | 89 func = function(record) |
bsw@51 | 90 return record.issue.state |
bsw@51 | 91 end |
bsw@51 | 92 }, |
bsw@51 | 93 { |
bsw@51 | 94 name = "issue_created", |
bsw@51 | 95 field = "issue.created", |
bsw@51 | 96 func = function(record) |
bsw@51 | 97 return format_timestamp(record.issue_created) |
bsw@51 | 98 end |
bsw@51 | 99 }, |
bsw@51 | 100 { |
bsw@51 | 101 name = "issue_accepted", |
bsw@51 | 102 field = "issue.accepted", |
bsw@51 | 103 func = function(record) |
bsw@51 | 104 return format_timestamp(record.issue_accepted) |
bsw@51 | 105 end |
bsw@51 | 106 }, |
bsw@51 | 107 { |
bsw@51 | 108 name = "issue_half_frozen", |
bsw@51 | 109 field = "issue.half_frozen", |
bsw@51 | 110 func = function(record) |
bsw@51 | 111 return format_timestamp(record.issue_half_frozen) |
bsw@51 | 112 end |
bsw@51 | 113 }, |
bsw@51 | 114 { |
bsw@51 | 115 name = "issue_fully_frozen", |
bsw@51 | 116 field = "issue.fully_frozen", |
bsw@51 | 117 func = function(record) |
bsw@51 | 118 return format_timestamp(record.issue_fully_frozen) |
bsw@51 | 119 end |
bsw@51 | 120 }, |
bsw@51 | 121 { |
bsw@51 | 122 name = "issue_closed", |
bsw@51 | 123 field = "issue.closed", |
bsw@51 | 124 func = function(record) |
bsw@51 | 125 return format_timestamp(record.issue_closed) |
bsw@51 | 126 end |
bsw@51 | 127 }, |
bsw@51 | 128 { name = "issue_admission_time", field = "issue.admission_time" }, |
bsw@51 | 129 { name = "issue_discussion_time", field = "issue.discussion_time" }, |
bsw@51 | 130 { name = "issue_verification_time", field = "issue.verification_time" }, |
bsw@51 | 131 { name = "issue_voting_time", field = "issue.voting_time" }, |
bsw@51 | 132 { name = "issue_ranks_available", field = "issue.ranks_available" }, |
bsw@51 | 133 |
bsw@51 | 134 { name = "policy_issue_quorum_num", field = "policy.issue_quorum_num" }, |
bsw@51 | 135 { name = "policy_issue_quorum_den", field = "policy.issue_quorum_den" }, |
bsw@51 | 136 { name = "policy_initiative_quorum_num", |
bsw@51 | 137 field = "policy.initiative_quorum_num" }, |
bsw@51 | 138 { name = "policy_initiative_quorum_den", |
bsw@51 | 139 field = "policy.initiative_quorum_den" }, |
bsw@51 | 140 { name = "policy_majority_num", field = "policy.majority_num" }, |
bsw@51 | 141 { name = "policy_majority_den", field = "policy.majority_den" }, |
bsw@51 | 142 { name = "policy_majority_strict", field = "policy.majority_strict" }, |
bsw@51 | 143 { name = "id", field = "initiative.id" }, |
bsw@51 | 144 { name = "name", field = "initiative.name" }, |
bsw@51 | 145 { name = "discussion_url", field = "initiative.discussion_url" }, |
bsw@51 | 146 { |
bsw@51 | 147 name = "created", |
bsw@51 | 148 field = "initiative.created", |
bsw@51 | 149 func = function(record) |
bsw@51 | 150 return format.timestamp(record.created) |
bsw@51 | 151 end |
bsw@51 | 152 }, |
bsw@51 | 153 { name = "revoked", field = "initiative.revoked" }, |
bsw@51 | 154 { name = "suggested_initiative_id", field = "initiative.suggested_initiative_id" }, |
bsw@51 | 155 { name = "admitted", field = "initiative.admitted" }, |
bsw@51 | 156 { name = "issue_population", field = "issue.population" }, |
bsw@51 | 157 { name = "supporter_count", field = "initiative.supporter_count" }, |
bsw@51 | 158 { name = "informed_supporter_count", field = "initiative.informed_supporter_count" }, |
bsw@51 | 159 { name = "satisfied_supporter_count", field = "initiative.satisfied_supporter_count" }, |
bsw@51 | 160 { name = "satisfied_informed_supporter_count", |
bsw@51 | 161 field = "initiative.satisfied_informed_supporter_count" }, |
bsw@51 | 162 { name = "issue_vote_now", field = "issue.vote_now" }, |
bsw@51 | 163 { name = "issue_vote_later", field = "issue.vote_later" }, |
bsw@51 | 164 { name = "issue_voter_count", field = "issue.voter_count" }, |
bsw@51 | 165 { name = "positive_votes", field = "initiative.positive_votes" }, |
bsw@51 | 166 { name = "negative_votes", field = "initiative.negative_votes" }, |
bsw@51 | 167 { name = "agreed", field = "initiative.agreed" }, |
bsw@51 | 168 { name = "rank", field = "initiative.rank" }, |
bsw@51 | 169 { |
bsw@51 | 170 name = "current_draft_created", |
bsw@51 | 171 func = function(record) |
bsw@51 | 172 return format.timestamp(record.current_draft.created) |
bsw@51 | 173 end |
bsw@51 | 174 }, |
bsw@51 | 175 { |
bsw@51 | 176 name = "current_draft_formatting_engine", |
bsw@51 | 177 func = function(record) |
bsw@51 | 178 return record.current_draft.formatting_engine |
bsw@51 | 179 end |
bsw@51 | 180 }, |
bsw@51 | 181 { |
bsw@51 | 182 name = "current_draft_content", |
bsw@51 | 183 func = function(record) |
bsw@51 | 184 return record.current_draft.content |
bsw@51 | 185 end |
bsw@51 | 186 } |
bsw@51 | 187 } |
bsw@51 | 188 |
bsw@51 | 189 util.autoapi{ |
bsw@75 | 190 relation_name = "initiative", |
bsw@51 | 191 selector = initiatives_selector, |
bsw@51 | 192 fields = fields, |
bsw@51 | 193 api_engine = api_engine |
bsw@51 | 194 } |