liquid_feedback_frontend
diff model/issue.lua @ 525:63d6549cc00b
Delegation chain preview improved, better visualisation of current context, code cleanup
author | bsw |
---|---|
date | Fri May 18 19:07:07 2012 +0200 (2012-05-18) |
parents | 76027e762c76 |
children | 5ca9de94cb13 |
line diff
1.1 --- a/model/issue.lua Tue Apr 17 00:07:04 2012 +0200 1.2 +++ b/model/issue.lua Fri May 18 19:07:07 2012 +0200 1.3 @@ -108,6 +108,58 @@ 1.4 ref = 'direct_voters' 1.5 } 1.6 1.7 +Issue:add_reference{ 1.8 + mode = "11", 1.9 + to = mondelefant.class_prototype, 1.10 + this_key = "id", 1.11 + that_key = "issue_id", 1.12 + ref = "delegation_info", 1.13 + back_ref = "issue", 1.14 + selector_generator = function(list, options) 1.15 + assert(options.member_id, "member_id mandatory for delegation_info") 1.16 + local ids = { sep = ", " } 1.17 + for i, object in ipairs(list) do 1.18 + local id = object.id 1.19 + if id ~= nil then 1.20 + ids[#ids+1] = {"?", id} 1.21 + end 1.22 + end 1.23 + local sub_selector = Issue:get_db_conn():new_selector() 1.24 + if #ids == 0 then 1.25 + return sub_selector:empty_list_mode() 1.26 + end 1.27 + sub_selector:from("issue") 1.28 + sub_selector:add_field("issue.id", "issue_id") 1.29 + sub_selector:add_field{ '(delegation_info(?, null, null, issue.id)).*', options.member_id } 1.30 + sub_selector:add_where{ 'issue.id IN ($)', ids } 1.31 + 1.32 + local selector = Issue:get_db_conn():new_selector() 1.33 + selector:add_from(sub_selector, "delegation_info") 1.34 + selector:left_join("member", "first_trustee", "first_trustee.id = delegation_info.first_trustee_id") 1.35 + selector:left_join("member", "other_trustee", "other_trustee.id = delegation_info.other_trustee_id") 1.36 + selector:add_field("delegation_info.*") 1.37 + selector:add_field("first_trustee.name", "first_trustee_name") 1.38 + selector:add_field("other_trustee.name", "other_trustee_name") 1.39 + return selector 1.40 + end 1.41 +} 1.42 + 1.43 +function Issue.list:load_delegation_info_once_for_member_id(member_id) 1.44 + if self._delegation_info_loaded_for_member_id ~= member_id then 1.45 + self:load("delegation_info", { member_id = member_id }) 1.46 + for i, issue in ipairs(self) do 1.47 + issue._delegation_info_loaded_for_member_id = member_id 1.48 + end 1.49 + self._delegation_info_loaded_for_member_id = member_id 1.50 + end 1.51 +end 1.52 + 1.53 +function Issue.object:load_delegation_info_once_for_member_id(member_id) 1.54 + if self._delegation_info_loaded_for_member_id ~= member_id then 1.55 + self:load("delegation_info", { member_id = member_id }) 1.56 + self._delegation_info_loaded_for_member_id = member_id 1.57 + end 1.58 +end 1.59 1.60 1.61 function Issue:get_state_name_for_state(value) 1.62 @@ -238,4 +290,8 @@ 1.63 state_names[#state_names+1] = Issue:get_state_name_for_state(state) 1.64 end 1.65 return table.concat(state_names, ", ") 1.66 +end 1.67 + 1.68 +function Issue.object_get:etherpad_url() 1.69 + return config.etherpad.base_url .. "p/" .. config.etherpad.group_id .. "$Issue" .. self.id 1.70 end 1.71 \ No newline at end of file