# HG changeset patch # User bsw # Date 1330205146 -3600 # Node ID c4dd225578d4eb48fdf1f90891009fde9f539986 # Parent d39fa6c0ff0b6e8f108feff7b69ae6daa2988885 Show only member with voting rights in unit for delegation diff -r d39fa6c0ff0b -r c4dd225578d4 app/main/delegation/new.lua --- a/app/main/delegation/new.lua Sat Feb 25 22:20:38 2012 +0100 +++ b/app/main/delegation/new.lua Sat Feb 25 22:25:46 2012 +0100 @@ -1,17 +1,22 @@ +local voting_right_unit_id + local unit = Unit:by_id(param.get("unit_id", atom.integer)) if unit then + voting_right_unit_id = unit.id slot.put_into("title", encode.html(config.single_unit_id and _"Set global delegation" or _"Set unit delegation")) util.help("delegation.new.unit") end local area = Area:by_id(param.get("area_id", atom.integer)) if area then + voting_right_unit_id = area.unit_id slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name))) util.help("delegation.new.area") end local issue = Issue:by_id(param.get("issue_id", atom.integer)) if issue then + voting_right_unit_id = issue.area.unit_id slot.put_into("title", encode.html(_"Set delegation for Issue ##{number} in Area '#{area_name}'":gsub("#{number}", issue.id):gsub("#{area_name}", issue.area.name))) util.help("delegation.new.issue") end @@ -54,6 +59,7 @@ local contact_members = Member:build_selector{ is_contact_of_member_id = app.session.member_id, + voting_right_for_unit_id = voting_right_unit_id, order = "name" }:exec() diff -r d39fa6c0ff0b -r c4dd225578d4 model/member.lua --- a/model/member.lua Sat Feb 25 22:20:38 2012 +0100 +++ b/model/member.lua Sat Feb 25 22:25:46 2012 +0100 @@ -249,6 +249,9 @@ selector:join("contact", "__model_member__contact", "member.id = __model_member__contact.other_member_id") selector:add_where{ "__model_member__contact.member_id = ?", args.is_contact_of_member_id } end + if args.voting_right_for_unit_id then + selector:join("privilege", "__model_member__privilege", "member.id = __model_member__privilege.member_id AND __model_member__privilege.voting_right") + end if args.order then if args.order == "id" then selector:add_order_by("id")