liquid_feedback_frontend
annotate 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 |
rev | line source |
---|---|
bsw@95 | 1 local id = param.get("id") |
bsw@95 | 2 local min_id = param.get("min_id") |
bsw@95 | 3 local max_id = param.get("max_id") |
bsw@95 | 4 local initiative_id = param.get("initiative_id") |
bsw@95 | 5 local order = param.get("order") |
bsw@95 | 6 local limit = param.get("limit", atom.integer) |
bsw@95 | 7 |
bsw@95 | 8 local suggestions_selector = Suggestion:new_selector() |
bsw@95 | 9 |
bsw@95 | 10 if id then |
bsw@95 | 11 suggestions_selector:add_where{"suggestion.id = ?", id} |
bsw@95 | 12 end |
bsw@95 | 13 |
bsw@95 | 14 if min_id then |
bsw@95 | 15 suggestions_selector:add_where{"suggestion.id >= ?", min_id} |
bsw@95 | 16 end |
bsw@95 | 17 |
bsw@95 | 18 if max_id then |
bsw@95 | 19 suggestions_selector:add_where{"suggestion.id <= ?", max_id} |
bsw@95 | 20 end |
bsw@95 | 21 |
bsw@95 | 22 if order == "id_desc" then |
bsw@95 | 23 suggestions_selector:add_order_by("suggestion.id DESC") |
bsw@95 | 24 else |
bsw@95 | 25 suggestions_selector:add_order_by("suggestion.id") |
bsw@95 | 26 end |
bsw@95 | 27 |
bsw@95 | 28 if limit then |
bsw@95 | 29 suggestions_selector:limit(limit) |
bsw@95 | 30 end |
bsw@95 | 31 |
bsw@95 | 32 local api_engine = param.get("api_engine") or "xml" |
bsw@95 | 33 |
bsw@95 | 34 local fields = { |
bsw@95 | 35 |
bsw@95 | 36 { name = "id", field = "suggestion.id" }, |
bsw@95 | 37 { name = "initiative_id", field = "suggestion.initiative_id" }, |
bsw@95 | 38 { name = "name", field = "suggestion.name" }, |
bsw@95 | 39 { name = "description", field = "suggestion.description" }, |
bsw@95 | 40 { name = "minus2_unfulfilled_count", field = "suggestion.minus2_unfulfilled_count" }, |
bsw@95 | 41 { name = "minus2_fulfilled_count", field = "suggestion.minus2_fulfilled_count" }, |
bsw@95 | 42 { name = "minus1_unfulfilled_count", field = "suggestion.minus1_unfulfilled_count" }, |
bsw@95 | 43 { name = "minus1_fulfilled_count", field = "suggestion.minus1_fulfilled_count" }, |
bsw@95 | 44 { name = "plus1_unfulfilled_count", field = "suggestion.plus1_unfulfilled_count" }, |
bsw@95 | 45 { name = "plus1_fulfilled_count", field = "suggestion.plus1_fulfilled_count" }, |
bsw@95 | 46 { name = "plus2_unfulfilled_count", field = "suggestion.plus2_unfulfilled_count" }, |
bsw@95 | 47 { name = "plus2_fulfilled_count", field = "suggestion.plus2_fulfilled_count" }, |
bsw@95 | 48 |
bsw@95 | 49 } |
bsw@95 | 50 |
bsw@95 | 51 util.autoapi{ |
bsw@95 | 52 relation_name = "suggestion", |
bsw@95 | 53 selector = suggestions_selector, |
bsw@95 | 54 fields = fields, |
bsw@95 | 55 api_engine = api_engine |
bsw@95 | 56 } |