liquid_feedback_frontend
annotate model/initiative.lua @ 11:77d58efe99fd
Version beta7
Important security fixes:
- Added missing HTML encoding to postal address of member
- Link to discussion URL only if it starts with http(s)://
Other bugfixes:
- Fixed wrong display of 2nd level delegating voters for an initiative
- Do not display invited initiators as initiators while voting
- Added missing translation
New features:
- Public message of the day
- Both direct and indirect supporter count is shown in tab heads
- Support shown in initiative lists
Language chooser at the login page has been added (again)
Important security fixes:
- Added missing HTML encoding to postal address of member
- Link to discussion URL only if it starts with http(s)://
Other bugfixes:
- Fixed wrong display of 2nd level delegating voters for an initiative
- Do not display invited initiators as initiators while voting
- Added missing translation
New features:
- Public message of the day
- Both direct and indirect supporter count is shown in tab heads
- Support shown in initiative lists
Language chooser at the login page has been added (again)
author | bsw |
---|---|
date | Fri Jan 22 12:00:00 2010 +0100 (2010-01-22) |
parents | 72c5e0ee7c98 |
children | 00d1004545f1 |
rev | line source |
---|---|
bsw/jbe@0 | 1 Initiative = mondelefant.new_class() |
bsw/jbe@0 | 2 Initiative.table = 'initiative' |
bsw/jbe@0 | 3 |
bsw/jbe@0 | 4 Initiative:add_reference{ |
bsw/jbe@0 | 5 mode = 'm1', |
bsw/jbe@0 | 6 to = "Issue", |
bsw/jbe@0 | 7 this_key = 'issue_id', |
bsw/jbe@0 | 8 that_key = 'id', |
bsw/jbe@0 | 9 ref = 'issue', |
bsw/jbe@0 | 10 } |
bsw/jbe@0 | 11 |
bsw/jbe@0 | 12 Initiative:add_reference{ |
bsw/jbe@0 | 13 mode = '1m', |
bsw/jbe@0 | 14 to = "Draft", |
bsw/jbe@0 | 15 this_key = 'id', |
bsw/jbe@0 | 16 that_key = 'initiative_id', |
bsw/jbe@0 | 17 ref = 'drafts', |
bsw/jbe@0 | 18 back_ref = 'initiative', |
bsw/jbe@0 | 19 default_order = '"id"' |
bsw/jbe@0 | 20 } |
bsw/jbe@0 | 21 |
bsw/jbe@0 | 22 Initiative:add_reference{ |
bsw/jbe@0 | 23 mode = '1m', |
bsw/jbe@0 | 24 to = "Suggestion", |
bsw/jbe@0 | 25 this_key = 'id', |
bsw/jbe@0 | 26 that_key = 'initiative_id', |
bsw/jbe@0 | 27 ref = 'suggestions', |
bsw/jbe@0 | 28 back_ref = 'initiative', |
bsw/jbe@0 | 29 } |
bsw/jbe@0 | 30 |
bsw/jbe@0 | 31 Initiative:add_reference{ |
bsw/jbe@0 | 32 mode = '1m', |
bsw/jbe@0 | 33 to = "Initiator", |
bsw/jbe@0 | 34 this_key = 'id', |
bsw/jbe@0 | 35 that_key = 'initiative_id', |
bsw/jbe@0 | 36 ref = 'initiators', |
bsw@10 | 37 back_ref = 'initiative' |
bsw/jbe@0 | 38 } |
bsw/jbe@0 | 39 |
bsw/jbe@0 | 40 Initiative:add_reference{ |
bsw/jbe@0 | 41 mode = '1m', |
bsw/jbe@0 | 42 to = "Supporter", |
bsw/jbe@0 | 43 this_key = 'id', |
bsw/jbe@0 | 44 that_key = 'initiative_id', |
bsw/jbe@0 | 45 ref = 'supporters', |
bsw/jbe@0 | 46 back_ref = 'initiative', |
bsw/jbe@0 | 47 default_order = '"id"' |
bsw/jbe@0 | 48 } |
bsw/jbe@0 | 49 |
bsw/jbe@0 | 50 Initiative:add_reference{ |
bsw/jbe@0 | 51 mode = '1m', |
bsw/jbe@0 | 52 to = "Opinion", |
bsw/jbe@0 | 53 this_key = 'id', |
bsw/jbe@0 | 54 that_key = 'initiative_id', |
bsw/jbe@0 | 55 ref = 'opinions', |
bsw/jbe@0 | 56 back_ref = 'initiative', |
bsw/jbe@0 | 57 default_order = '"id"' |
bsw/jbe@0 | 58 } |
bsw/jbe@0 | 59 |
bsw/jbe@0 | 60 Initiative:add_reference{ |
bsw/jbe@0 | 61 mode = '1m', |
bsw/jbe@0 | 62 to = "Vote", |
bsw/jbe@0 | 63 this_key = 'id', |
bsw/jbe@0 | 64 that_key = 'initiative_id', |
bsw/jbe@0 | 65 ref = 'votes', |
bsw/jbe@0 | 66 back_ref = 'initiative', |
bsw/jbe@0 | 67 default_order = '"member_id"' |
bsw/jbe@0 | 68 } |
bsw/jbe@0 | 69 |
bsw/jbe@0 | 70 Initiative:add_reference{ |
bsw@10 | 71 mode = 'm1', |
bsw@10 | 72 to = "Initiative", |
bsw@10 | 73 this_key = 'suggested_initiative_id', |
bsw@10 | 74 that_key = 'id', |
bsw@10 | 75 ref = 'suggested_initiative', |
bsw@10 | 76 } |
bsw@10 | 77 |
bsw@10 | 78 Initiative:add_reference{ |
bsw/jbe@0 | 79 mode = 'mm', |
bsw/jbe@0 | 80 to = "Member", |
bsw/jbe@0 | 81 this_key = 'id', |
bsw/jbe@0 | 82 that_key = 'id', |
bsw/jbe@0 | 83 connected_by_table = '"initiator"', |
bsw/jbe@0 | 84 connected_by_this_key = 'initiative_id', |
bsw/jbe@0 | 85 connected_by_that_key = 'member_id', |
bsw/jbe@0 | 86 ref = 'initiating_members' |
bsw/jbe@0 | 87 } |
bsw/jbe@0 | 88 |
bsw/jbe@0 | 89 Initiative:add_reference{ |
bsw/jbe@0 | 90 mode = 'mm', |
bsw/jbe@0 | 91 to = "Member", |
bsw/jbe@0 | 92 this_key = 'id', |
bsw/jbe@0 | 93 that_key = 'id', |
bsw/jbe@0 | 94 connected_by_table = '"supporter"', |
bsw/jbe@0 | 95 connected_by_this_key = 'initiative_id', |
bsw/jbe@0 | 96 connected_by_that_key = 'member_id', |
bsw/jbe@0 | 97 ref = 'supporting_members' |
bsw/jbe@0 | 98 } |
bsw/jbe@0 | 99 |
bsw@3 | 100 Initiative:add_reference{ |
bsw@3 | 101 mode = 'mm', |
bsw@3 | 102 to = "Member", |
bsw@3 | 103 this_key = 'id', |
bsw@3 | 104 that_key = 'id', |
bsw@3 | 105 connected_by_table = 'direct_supporter_snapshot', |
bsw@3 | 106 connected_by_this_key = 'initiative_id', |
bsw@3 | 107 connected_by_that_key = 'member_id', |
bsw@3 | 108 ref = 'supporting_members_snapshot' |
bsw@3 | 109 } |
bsw@3 | 110 |
bsw/jbe@6 | 111 |
bsw@2 | 112 function Initiative:get_search_selector(search_string) |
bsw/jbe@0 | 113 return self:new_selector() |
bsw/jbe@6 | 114 :join("draft", nil, "draft.initiative_id = initiative.id") |
bsw@2 | 115 :add_field( {'"highlight"("initiative"."name", ?)', search_string }, "name_highlighted") |
bsw/jbe@6 | 116 :add_where{ '"initiative"."text_search_data" @@ "text_search_query"(?) OR "draft"."text_search_data" @@ "text_search_query"(?)', search_string, search_string } |
bsw/jbe@6 | 117 :add_group_by('"initiative"."id"') |
bsw/jbe@6 | 118 :add_group_by('"initiative"."issue_id"') |
bsw/jbe@6 | 119 :add_group_by('"initiative"."name"') |
bsw/jbe@6 | 120 :add_group_by('"initiative"."discussion_url"') |
bsw/jbe@6 | 121 :add_group_by('"initiative"."created"') |
bsw/jbe@6 | 122 :add_group_by('"initiative"."revoked"') |
bsw/jbe@6 | 123 :add_group_by('"initiative"."admitted"') |
bsw/jbe@6 | 124 :add_group_by('"initiative"."supporter_count"') |
bsw/jbe@6 | 125 :add_group_by('"initiative"."informed_supporter_count"') |
bsw/jbe@6 | 126 :add_group_by('"initiative"."satisfied_supporter_count"') |
bsw/jbe@6 | 127 :add_group_by('"initiative"."satisfied_informed_supporter_count"') |
bsw/jbe@6 | 128 :add_group_by('"initiative"."positive_votes"') |
bsw/jbe@6 | 129 :add_group_by('"initiative"."negative_votes"') |
bsw/jbe@6 | 130 :add_group_by('"initiative"."agreed"') |
bsw/jbe@6 | 131 :add_group_by('"initiative"."rank"') |
bsw/jbe@6 | 132 :add_group_by('"initiative"."text_search_data"') |
bsw/jbe@6 | 133 :add_group_by('"issue"."population"') |
bsw/jbe@0 | 134 end |
bsw/jbe@0 | 135 |
bsw@2 | 136 function Member:get_search_selector(search_string) |
bsw@2 | 137 return self:new_selector() |
bsw@2 | 138 :add_where("active") |
bsw@2 | 139 end |
bsw@2 | 140 |
bsw@2 | 141 |
bsw/jbe@0 | 142 function Initiative.object_get:current_draft() |
bsw/jbe@0 | 143 return Draft:new_selector() |
bsw/jbe@0 | 144 :add_where{ '"initiative_id" = ?', self.id } |
bsw/jbe@0 | 145 :add_order_by('"id" DESC') |
bsw/jbe@0 | 146 :single_object_mode() |
bsw/jbe@0 | 147 :exec() |
bsw/jbe@0 | 148 end |
bsw/jbe@0 | 149 |
bsw/jbe@0 | 150 function Initiative.object_get:shortened_name() |
bsw/jbe@0 | 151 local name = self.name |
bsw/jbe@0 | 152 if #name > 100 then |
bsw/jbe@0 | 153 name = name:sub(1,100) .. "..." |
bsw/jbe@0 | 154 end |
bsw/jbe@0 | 155 return name |
bsw/jbe@0 | 156 end |