liquid_feedback_frontend
diff model/member.lua @ 281:b77e6a17ca77
Check unit voting right where neccessary, hide action buttons for units without voting right
author | bsw |
---|---|
date | Thu Feb 16 15:01:49 2012 +0100 (2012-02-16) |
parents | 23c98752e697 |
children | c587d8762e62 |
line diff
1.1 --- a/model/member.lua Thu Feb 16 14:08:55 2012 +0100 1.2 +++ b/model/member.lua Thu Feb 16 15:01:49 2012 +0100 1.3 @@ -181,6 +181,17 @@ 1.4 1.5 Member:add_reference{ 1.6 mode = 'mm', 1.7 + to = "Unit", 1.8 + this_key = 'id', 1.9 + that_key = 'id', 1.10 + connected_by_table = 'privilege', 1.11 + connected_by_this_key = 'member_id', 1.12 + connected_by_that_key = 'unit_id', 1.13 + ref = 'units' 1.14 +} 1.15 + 1.16 +Member:add_reference{ 1.17 + mode = 'mm', 1.18 to = "Area", 1.19 this_key = 'id', 1.20 that_key = 'id', 1.21 @@ -432,3 +443,13 @@ 1.22 ui.field.text{ label = args.label, value = _"[not displayed public]" } 1.23 end 1.24 end 1.25 + 1.26 +function Member.object:has_voting_right_for_unit_id(unit_id) 1.27 + return (Privilege:new_selector() 1.28 + :add_where{ "member_id = ?", self.id } 1.29 + :add_where{ "unit_id = ?", unit_id } 1.30 + :add_where("voting_right") 1.31 + :optional_object_mode() 1.32 + :for_share() 1.33 + :exec()) and true or false 1.34 +end 1.35 \ No newline at end of file