liquid_feedback_frontend
view app/main/api/suggestion.lua @ 124:f740026b1518
add initiator support in delegation
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Mon Sep 20 20:32:04 2010 +0200 (2010-09-20) |
parents | 6a12fb7e4963 |
children | a33abf457d29 |
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 initiative_id = param.get("initiative_id")
5 local order = param.get("order")
6 local limit = param.get("limit", atom.integer)
8 local suggestions_selector = Suggestion:new_selector()
10 if id then
11 suggestions_selector:add_where{"suggestion.id = ?", id}
12 end
14 if min_id then
15 suggestions_selector:add_where{"suggestion.id >= ?", min_id}
16 end
18 if max_id then
19 suggestions_selector:add_where{"suggestion.id <= ?", max_id}
20 end
22 if order == "id_desc" then
23 suggestions_selector:add_order_by("suggestion.id DESC")
24 else
25 suggestions_selector:add_order_by("suggestion.id")
26 end
28 if limit then
29 suggestions_selector:limit(limit)
30 end
32 local api_engine = param.get("api_engine") or "xml"
34 local fields = {
36 { name = "id", field = "suggestion.id" },
37 { name = "initiative_id", field = "suggestion.initiative_id" },
38 { name = "name", field = "suggestion.name" },
39 { name = "description", field = "suggestion.description" },
40 { name = "minus2_unfulfilled_count", field = "suggestion.minus2_unfulfilled_count" },
41 { name = "minus2_fulfilled_count", field = "suggestion.minus2_fulfilled_count" },
42 { name = "minus1_unfulfilled_count", field = "suggestion.minus1_unfulfilled_count" },
43 { name = "minus1_fulfilled_count", field = "suggestion.minus1_fulfilled_count" },
44 { name = "plus1_unfulfilled_count", field = "suggestion.plus1_unfulfilled_count" },
45 { name = "plus1_fulfilled_count", field = "suggestion.plus1_fulfilled_count" },
46 { name = "plus2_unfulfilled_count", field = "suggestion.plus2_unfulfilled_count" },
47 { name = "plus2_fulfilled_count", field = "suggestion.plus2_fulfilled_count" },
49 }
51 util.autoapi{
52 relation_name = "suggestion",
53 selector = suggestions_selector,
54 fields = fields,
55 api_engine = api_engine
56 }