liquid_feedback_frontend
annotate app/main/initiative/list_rss.lua @ 118:93f4e465b50d
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 | 733f65c0c0a0 |
children |
rev | line source |
---|---|
bsw/jbe@52 | 1 if not config.feature_rss_enabled then |
bsw/jbe@52 | 2 error("feature not enabled") |
bsw/jbe@52 | 3 end |
bsw/jbe@52 | 4 |
bsw/jbe@52 | 5 local area_id = param.get("area_id", atom.integer) |
bsw/jbe@52 | 6 local issue_id = param.get("issue_id", atom.integer) |
bsw/jbe@52 | 7 local order = param.get("order") or "last_created" |
bsw/jbe@52 | 8 |
bsw/jbe@52 | 9 local initiatives_selector = Initiative:new_selector() |
bsw/jbe@52 | 10 |
bsw/jbe@52 | 11 local issue |
bsw/jbe@52 | 12 local area |
bsw/jbe@52 | 13 |
bsw/jbe@52 | 14 if issue_id then |
bsw/jbe@52 | 15 issue = Issue:by_id(issue_id) |
bsw/jbe@52 | 16 initiatives_selector:add_where{ "initiative.issue_id = ?", issue_id } |
bsw/jbe@52 | 17 elseif area_id then |
bsw/jbe@52 | 18 area = Area:by_id(area_id) |
bsw/jbe@52 | 19 initiatives_selector:join("issue", nil, "issue.id = initiative.issue_id") |
bsw/jbe@52 | 20 initiatives_selector:add_where{ "issue.area_id = ?", area_id } |
bsw/jbe@52 | 21 end |
bsw/jbe@52 | 22 |
bsw/jbe@52 | 23 |
bsw/jbe@52 | 24 if order == "last_created" then |
bsw/jbe@52 | 25 initiatives_selector:add_order_by("initiative.created DESC") |
bsw/jbe@52 | 26 initiatives_selector:add_field("initiative.created", "created_or_updated") |
bsw/jbe@52 | 27 elseif order == "last_updated" then |
bsw/jbe@52 | 28 initiatives_selector:add_field("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id)", "created_or_updated") |
bsw/jbe@52 | 29 initiatives_selector:add_order_by("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id) DESC") |
bsw/jbe@52 | 30 else |
bsw/jbe@52 | 31 error("Invalid order") |
bsw/jbe@52 | 32 end |
bsw/jbe@52 | 33 |
bsw/jbe@52 | 34 initiatives_selector:add_order_by("id DESC") |
bsw/jbe@52 | 35 |
bsw/jbe@52 | 36 initiatives_selector:limit(25) |
bsw/jbe@52 | 37 |
bsw/jbe@52 | 38 local initiatives = initiatives_selector:exec() |
bsw/jbe@52 | 39 |
bsw/jbe@19 | 40 slot.set_layout("atom") |
bsw/jbe@19 | 41 request.force_absolute_baseurl() |
bsw/jbe@19 | 42 |
bsw/jbe@52 | 43 ui.tag{ |
bsw/jbe@52 | 44 tag = "author", |
bsw/jbe@52 | 45 content = function() |
bsw/jbe@52 | 46 ui.tag{ |
bsw/jbe@52 | 47 tag = "name", |
bsw/jbe@52 | 48 content = "LiquidFeedback" |
bsw/jbe@52 | 49 } |
bsw/jbe@52 | 50 end |
bsw/jbe@52 | 51 } |
bsw/jbe@52 | 52 |
bsw/jbe@52 | 53 local title |
bsw/jbe@52 | 54 |
bsw/jbe@52 | 55 if issue then |
bsw/jbe@52 | 56 title = "#" .. tostring(issue.id) .. " " .. issue.area.name |
bsw/jbe@52 | 57 elseif area then |
bsw/jbe@52 | 58 title = area.name |
bsw/jbe@52 | 59 else |
bsw/jbe@52 | 60 title = config.app_title |
bsw/jbe@52 | 61 end |
bsw/jbe@52 | 62 |
bsw/jbe@52 | 63 ui.tag{ |
bsw/jbe@52 | 64 tag = "title", |
bsw/jbe@52 | 65 content = title |
bsw/jbe@52 | 66 } |
bsw/jbe@52 | 67 |
bsw/jbe@52 | 68 local subtitle |
bsw/jbe@52 | 69 if order == "last_created" then |
bsw/jbe@52 | 70 subtitle = "Initiatives (last created first)" |
bsw/jbe@52 | 71 elseif order == "last_updated" then |
bsw/jbe@52 | 72 subtitle = "Initiatives (last updated first)" |
bsw/jbe@52 | 73 end |
bsw/jbe@52 | 74 |
bsw/jbe@52 | 75 ui.tag{ |
bsw/jbe@52 | 76 tag = "subtitle", |
bsw/jbe@52 | 77 content = subtitle |
bsw/jbe@52 | 78 } |
bsw/jbe@52 | 79 |
bsw/jbe@52 | 80 ui.tag{ |
bsw/jbe@52 | 81 tag = "id", |
bsw@75 | 82 -- content = "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6" |
bsw/jbe@52 | 83 } |
bsw/jbe@52 | 84 |
bsw@75 | 85 --[[ |
bsw/jbe@52 | 86 ui.tag{ |
bsw/jbe@52 | 87 tag = "updated", |
bsw/jbe@52 | 88 content = "2003-12-14T10:20:09Z" |
bsw/jbe@52 | 89 } |
bsw@75 | 90 --]] |
bsw/jbe@19 | 91 |
bsw/jbe@19 | 92 for i, initiative in ipairs(initiatives) do |
bsw/jbe@19 | 93 ui.tag{ |
bsw/jbe@19 | 94 tag = "entry", |
bsw/jbe@19 | 95 content = function() |
bsw/jbe@52 | 96 slot.put("\n") |
bsw/jbe@52 | 97 ui.tag{ tag = "category", attr = { term = encode.html(initiative.issue.area.name) } } |
bsw/jbe@52 | 98 slot.put("\n") |
bsw/jbe@52 | 99 ui.tag{ tag = "author", content = encode.html(initiative.current_draft.author.name) } |
bsw/jbe@52 | 100 slot.put("\n") |
bsw/jbe@52 | 101 ui.tag{ tag = "title", content = encode.html(initiative.shortened_name) } |
bsw/jbe@52 | 102 slot.put("\n") |
bsw/jbe@19 | 103 ui.tag{ tag = "link", attr = { |
bsw/jbe@19 | 104 href = encode.url{ |
bsw/jbe@19 | 105 module = "initiative", |
bsw/jbe@19 | 106 view = "show", |
bsw/jbe@19 | 107 id = initiative.id |
bsw/jbe@19 | 108 } |
bsw/jbe@19 | 109 } } |
bsw/jbe@52 | 110 slot.put("\n") |
bsw/jbe@52 | 111 ui.tag{ tag = "id", content = "initiative_" .. tostring(initiative.id) } |
bsw/jbe@52 | 112 slot.put("\n") |
bsw/jbe@52 | 113 ui.tag{ tag = "updated", content = tostring(initiative.created_or_updated) } |
bsw/jbe@52 | 114 slot.put("\n") |
bsw/jbe@52 | 115 ui.tag{ tag = "content", content = encode.html(initiative.current_draft.content or "") } |
bsw/jbe@52 | 116 slot.put("\n") |
bsw/jbe@19 | 117 end |
bsw/jbe@19 | 118 } |
bsw/jbe@52 | 119 slot.put("\n") |
bsw/jbe@52 | 120 end |