bsw/jbe@0: Issue = mondelefant.new_class() bsw/jbe@0: Issue.table = 'issue' bsw/jbe@0: bsw/jbe@0: Issue:add_reference{ bsw/jbe@0: mode = 'm1', bsw/jbe@0: to = "Area", bsw/jbe@0: this_key = 'area_id', bsw/jbe@0: that_key = 'id', bsw/jbe@0: ref = 'area', bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: Issue:add_reference{ bsw/jbe@0: mode = 'm1', bsw/jbe@0: to = "Policy", bsw/jbe@0: this_key = 'policy_id', bsw/jbe@0: that_key = 'id', bsw/jbe@0: ref = 'policy', bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: Issue:add_reference{ bsw/jbe@0: mode = '1m', bsw/jbe@0: to = "Initiative", bsw/jbe@0: this_key = 'id', bsw/jbe@0: that_key = 'issue_id', bsw/jbe@0: ref = 'initiatives', bsw/jbe@0: back_ref = 'issue' bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: Issue:add_reference{ bsw/jbe@0: mode = '1m', bsw/jbe@0: to = "Interest", bsw/jbe@0: this_key = 'id', bsw/jbe@0: that_key = 'issue_id', bsw/jbe@0: ref = 'interests', bsw/jbe@0: back_ref = 'issue', bsw/jbe@0: default_order = '"id"' bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: Issue:add_reference{ bsw/jbe@0: mode = '1m', bsw/jbe@0: to = "Supporter", bsw/jbe@0: this_key = 'id', bsw/jbe@0: that_key = 'issue_id', bsw/jbe@0: ref = 'supporters', bsw/jbe@0: back_ref = 'issue', bsw/jbe@0: default_order = '"id"' bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: Issue:add_reference{ bsw/jbe@0: mode = '1m', bsw/jbe@0: to = "DirectVoter", bsw/jbe@0: this_key = 'id', bsw/jbe@0: that_key = 'issue_id', bsw/jbe@0: ref = 'direct_voters', bsw/jbe@0: back_ref = 'issue', bsw/jbe@0: default_order = '"member_id"' bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: Issue:add_reference{ bsw/jbe@0: mode = '1m', bsw/jbe@0: to = "Vote", bsw/jbe@0: this_key = 'id', bsw/jbe@0: that_key = 'issue_id', bsw/jbe@0: ref = 'votes', bsw/jbe@0: back_ref = 'issue', bsw/jbe@0: default_order = '"member_id", "initiative_id"' bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: Issue:add_reference{ bsw/jbe@0: mode = 'mm', bsw/jbe@0: to = "Member", bsw/jbe@0: this_key = 'id', bsw/jbe@0: that_key = 'id', bsw/jbe@0: connected_by_table = 'interest', bsw/jbe@0: connected_by_this_key = 'issue_id', bsw/jbe@0: connected_by_that_key = 'member_id', bsw/jbe@0: ref = 'members' bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: function Issue:get_state_name_for_state(value) bsw/jbe@0: local state_name_table = {} bsw/jbe@0: return state_name_table[value] or value bsw/jbe@0: end bsw/jbe@0: bsw/jbe@0: function Issue:search(search_string) bsw/jbe@0: return self:new_selector() bsw/jbe@0: :join('"initiative"', nil, '"initiative"."issue_id" = "issue"."id"') bsw/jbe@0: :add_where{ '"initiative"."name" ILIKE ?', "%" .. search_string:gsub("%%", "") .. "%" } bsw/jbe@0: :set_distinct() bsw/jbe@0: :exec() bsw/jbe@0: end bsw/jbe@0: bsw/jbe@0: function Issue.object_get:state() bsw/jbe@0: if self.accepted then bsw/jbe@0: if self.frozen then bsw/jbe@0: return "frozen" bsw/jbe@0: elseif self.closed then bsw/jbe@0: return "closed" bsw/jbe@0: else bsw/jbe@0: return "accepted" bsw/jbe@0: end bsw/jbe@0: else bsw/jbe@0: if self.closed then bsw/jbe@0: return "closed" bsw/jbe@0: else bsw/jbe@0: return "new" bsw/jbe@0: end bsw/jbe@0: end bsw/jbe@0: end