liquid_feedback_frontend
diff app/main/delegation/new.lua @ 248:e3613831cd1e
Migrate global delegation to unit level
| author | bsw |
|---|---|
| date | Fri Dec 30 03:13:10 2011 +0100 (2011-12-30) |
| parents | e60a26bf535b |
| children | 1b8d51e21614 |
line diff
1.1 --- a/app/main/delegation/new.lua Fri Dec 30 03:11:57 2011 +0100 1.2 +++ b/app/main/delegation/new.lua Fri Dec 30 03:13:10 2011 +0100 1.3 @@ -1,3 +1,9 @@ 1.4 +local unit = Unit:by_id(param.get("unit_id", atom.integer)) 1.5 +if unit then 1.6 + slot.put_into("title", encode.html(_"Set unit delegation")) 1.7 + util.help("delegation.new.unit") 1.8 +end 1.9 + 1.10 local area = Area:by_id(param.get("area_id", atom.integer)) 1.11 if area then 1.12 slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name))) 1.13 @@ -12,11 +18,6 @@ 1.14 1.15 local initiative = Initiative:by_id(param.get("initiative_id", atom.integer)) 1.16 1.17 -if not area and not issue then 1.18 - slot.put_into("title", encode.html(_"Set global delegation")) 1.19 - util.help("delegation.new.global") 1.20 -end 1.21 - 1.22 slot.select("actions", function() 1.23 if issue then 1.24 ui.link{ 1.25 @@ -61,6 +62,7 @@ 1.26 module = "delegation", 1.27 action = "update", 1.28 params = { 1.29 + unit_id = unit and unit.id or nil, 1.30 area_id = area and area.id or nil, 1.31 issue_id = issue and issue.id or nil, 1.32 }, 1.33 @@ -78,44 +80,44 @@ 1.34 if issue then 1.35 local delegate_name = "" 1.36 local scope = "no delegation set" 1.37 - local area_delegation = Delegation:by_pk(app.session.member_id, issue.area_id) 1.38 + local area_delegation = Delegation:by_pk(app.session.member_id, nil, issue.area_id) 1.39 if area_delegation then 1.40 delegate_name = area_delegation.trustee and area_delegation.trustee.name or _"abandoned" 1.41 scope = _"area" 1.42 else 1.43 - local global_delegation = Delegation:by_pk(app.session.member_id) 1.44 - if global_delegation then 1.45 - delegate_name = global_delegation.trustee.name 1.46 - scope = _"global" 1.47 + local unit_delegation = Delegation:by_pk(app.session.member_id, issue.area.unit_id) 1.48 + if unit_delegation then 1.49 + delegate_name = unit_delegation.trustee.name 1.50 + scope = _"unit" 1.51 + end 1.52 end 1.53 - end 1.54 records = { 1.55 { 1.56 id = -1, 1.57 - name = _("Apply global or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.58 + name = _("Apply unit or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.59 }, 1.60 { 1.61 id = 0, 1.62 - name = _"Abandon global and area delegations for this issue" 1.63 + name = _"Abandon unit and area delegations for this issue" 1.64 }, 1.65 1.66 } 1.67 elseif area then 1.68 local delegate_name = "" 1.69 local scope = "no delegation set" 1.70 - local global_delegation = Delegation:by_pk(app.session.member_id) 1.71 - if global_delegation then 1.72 - delegate_name = global_delegation.trustee.name 1.73 - scope = _"global" 1.74 + local unit_delegation = Delegation:by_pk(app.session.member_id, area.unit_id) 1.75 + if unit_delegation then 1.76 + delegate_name = unit_delegation.trustee.name 1.77 + scope = _"unit" 1.78 end 1.79 records = { 1.80 { 1.81 id = -1, 1.82 - name = _("Apply global delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.83 + name = _("Apply unit delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.84 }, 1.85 { 1.86 id = 0, 1.87 - name = _"Abandon global delegation for this area" 1.88 + name = _"Abandon unit delegation for this area" 1.89 } 1.90 } 1.91