liquid_feedback_frontend

annotate model/issue.lua @ 0:3bfb2fcf7ab9

Version alpha1
author bsw/jbe
date Wed Nov 18 12:00:00 2009 +0100 (2009-11-18)
parents
children 5c601807d397
rev   line source
bsw/jbe@0 1 Issue = mondelefant.new_class()
bsw/jbe@0 2 Issue.table = 'issue'
bsw/jbe@0 3
bsw/jbe@0 4 Issue:add_reference{
bsw/jbe@0 5 mode = 'm1',
bsw/jbe@0 6 to = "Area",
bsw/jbe@0 7 this_key = 'area_id',
bsw/jbe@0 8 that_key = 'id',
bsw/jbe@0 9 ref = 'area',
bsw/jbe@0 10 }
bsw/jbe@0 11
bsw/jbe@0 12 Issue:add_reference{
bsw/jbe@0 13 mode = 'm1',
bsw/jbe@0 14 to = "Policy",
bsw/jbe@0 15 this_key = 'policy_id',
bsw/jbe@0 16 that_key = 'id',
bsw/jbe@0 17 ref = 'policy',
bsw/jbe@0 18 }
bsw/jbe@0 19
bsw/jbe@0 20 Issue:add_reference{
bsw/jbe@0 21 mode = '1m',
bsw/jbe@0 22 to = "Initiative",
bsw/jbe@0 23 this_key = 'id',
bsw/jbe@0 24 that_key = 'issue_id',
bsw/jbe@0 25 ref = 'initiatives',
bsw/jbe@0 26 back_ref = 'issue'
bsw/jbe@0 27 }
bsw/jbe@0 28
bsw/jbe@0 29 Issue:add_reference{
bsw/jbe@0 30 mode = '1m',
bsw/jbe@0 31 to = "Interest",
bsw/jbe@0 32 this_key = 'id',
bsw/jbe@0 33 that_key = 'issue_id',
bsw/jbe@0 34 ref = 'interests',
bsw/jbe@0 35 back_ref = 'issue',
bsw/jbe@0 36 default_order = '"id"'
bsw/jbe@0 37 }
bsw/jbe@0 38
bsw/jbe@0 39 Issue:add_reference{
bsw/jbe@0 40 mode = '1m',
bsw/jbe@0 41 to = "Supporter",
bsw/jbe@0 42 this_key = 'id',
bsw/jbe@0 43 that_key = 'issue_id',
bsw/jbe@0 44 ref = 'supporters',
bsw/jbe@0 45 back_ref = 'issue',
bsw/jbe@0 46 default_order = '"id"'
bsw/jbe@0 47 }
bsw/jbe@0 48
bsw/jbe@0 49 Issue:add_reference{
bsw/jbe@0 50 mode = '1m',
bsw/jbe@0 51 to = "DirectVoter",
bsw/jbe@0 52 this_key = 'id',
bsw/jbe@0 53 that_key = 'issue_id',
bsw/jbe@0 54 ref = 'direct_voters',
bsw/jbe@0 55 back_ref = 'issue',
bsw/jbe@0 56 default_order = '"member_id"'
bsw/jbe@0 57 }
bsw/jbe@0 58
bsw/jbe@0 59 Issue:add_reference{
bsw/jbe@0 60 mode = '1m',
bsw/jbe@0 61 to = "Vote",
bsw/jbe@0 62 this_key = 'id',
bsw/jbe@0 63 that_key = 'issue_id',
bsw/jbe@0 64 ref = 'votes',
bsw/jbe@0 65 back_ref = 'issue',
bsw/jbe@0 66 default_order = '"member_id", "initiative_id"'
bsw/jbe@0 67 }
bsw/jbe@0 68
bsw/jbe@0 69 Issue:add_reference{
bsw/jbe@0 70 mode = 'mm',
bsw/jbe@0 71 to = "Member",
bsw/jbe@0 72 this_key = 'id',
bsw/jbe@0 73 that_key = 'id',
bsw/jbe@0 74 connected_by_table = 'interest',
bsw/jbe@0 75 connected_by_this_key = 'issue_id',
bsw/jbe@0 76 connected_by_that_key = 'member_id',
bsw/jbe@0 77 ref = 'members'
bsw/jbe@0 78 }
bsw/jbe@0 79
bsw/jbe@0 80 function Issue:get_state_name_for_state(value)
bsw/jbe@0 81 local state_name_table = {}
bsw/jbe@0 82 return state_name_table[value] or value
bsw/jbe@0 83 end
bsw/jbe@0 84
bsw/jbe@0 85 function Issue:search(search_string)
bsw/jbe@0 86 return self:new_selector()
bsw/jbe@0 87 :join('"initiative"', nil, '"initiative"."issue_id" = "issue"."id"')
bsw/jbe@0 88 :add_where{ '"initiative"."name" ILIKE ?', "%" .. search_string:gsub("%%", "") .. "%" }
bsw/jbe@0 89 :set_distinct()
bsw/jbe@0 90 :exec()
bsw/jbe@0 91 end
bsw/jbe@0 92
bsw/jbe@0 93 function Issue.object_get:state()
bsw/jbe@0 94 if self.accepted then
bsw/jbe@0 95 if self.frozen then
bsw/jbe@0 96 return "frozen"
bsw/jbe@0 97 elseif self.closed then
bsw/jbe@0 98 return "closed"
bsw/jbe@0 99 else
bsw/jbe@0 100 return "accepted"
bsw/jbe@0 101 end
bsw/jbe@0 102 else
bsw/jbe@0 103 if self.closed then
bsw/jbe@0 104 return "closed"
bsw/jbe@0 105 else
bsw/jbe@0 106 return "new"
bsw/jbe@0 107 end
bsw/jbe@0 108 end
bsw/jbe@0 109 end

Impressum / About Us