liquid_feedback_frontend

changeset 248:e3613831cd1e

Migrate global delegation to unit level
author bsw
date Fri Dec 30 03:13:10 2011 +0100 (2011-12-30)
parents 8e284d4319be
children 52b125fada5b
files app/main/area/list.lua app/main/delegation/_action/update.lua app/main/delegation/_list.lua app/main/delegation/_show_box.lua app/main/delegation/new.lua app/main/index/index.lua model/delegation.lua
line diff
     1.1 --- a/app/main/area/list.lua	Fri Dec 30 03:11:57 2011 +0100
     1.2 +++ b/app/main/area/list.lua	Fri Dec 30 03:13:10 2011 +0100
     1.3 @@ -24,6 +24,12 @@
     1.4  
     1.5  util.help("area.list", _"Area list")
     1.6  
     1.7 +execute.view{
     1.8 +  module = "delegation",
     1.9 +  view = "_show_box",
    1.10 +  params = { unit_id = unit_id }
    1.11 +}
    1.12 +
    1.13  
    1.14  execute.view{
    1.15    module = "area",
     2.1 --- a/app/main/delegation/_action/update.lua	Fri Dec 30 03:11:57 2011 +0100
     2.2 +++ b/app/main/delegation/_action/update.lua	Fri Dec 30 03:13:10 2011 +0100
     2.3 @@ -2,6 +2,8 @@
     2.4  
     2.5  local trustee_id = param.get("trustee_id", atom.integer)
     2.6  
     2.7 +local unit_id = param.get("unit_id", atom.integer)
     2.8 +
     2.9  local area_id = param.get("area_id", atom.integer)
    2.10  
    2.11  local issue_id = param.get("issue_id", atom.integer)
    2.12 @@ -10,7 +12,7 @@
    2.13    area_id = nil
    2.14  end
    2.15  
    2.16 -local delegation = Delegation:by_pk(truster_id, area_id, issue_id)
    2.17 +local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
    2.18  
    2.19  if param.get("delete") or trustee_id == -1 then
    2.20  
    2.21 @@ -23,7 +25,7 @@
    2.22      elseif area_id then
    2.23        slot.put_into("notice", _"Your delegation for this area has been deleted.")
    2.24      else
    2.25 -      slot.put_into("notice", _"Your global delegation has been deleted.")
    2.26 +      slot.put_into("notice", _"Your delegation for this unit has been deleted.")
    2.27      end
    2.28  
    2.29    end
    2.30 @@ -33,14 +35,15 @@
    2.31    if not delegation then
    2.32      delegation = Delegation:new()
    2.33      delegation.truster_id = truster_id
    2.34 +    delegation.unit_id    = unit_id
    2.35      delegation.area_id    = area_id
    2.36      delegation.issue_id   = issue_id
    2.37      if issue_id then
    2.38        delegation.scope = "issue"
    2.39      elseif area_id then
    2.40        delegation.scope = "area"
    2.41 -    else
    2.42 -      delegation.scope = "global"
    2.43 +    elseif unit_id then
    2.44 +      delegation.scope = "unit"
    2.45      end
    2.46    end
    2.47    if trustee_id == 0 then
    2.48 @@ -56,7 +59,7 @@
    2.49    elseif area_id then
    2.50      slot.put_into("notice", _"Your delegation for this area has been updated.")
    2.51    else
    2.52 -    slot.put_into("notice", _"Your global delegation has been updated.")
    2.53 +    slot.put_into("notice", _"Your delegation for this unit has been updated.")
    2.54    end
    2.55  
    2.56  end
     3.1 --- a/app/main/delegation/_list.lua	Fri Dec 30 03:11:57 2011 +0100
     3.2 +++ b/app/main/delegation/_list.lua	Fri Dec 30 03:13:10 2011 +0100
     3.3 @@ -13,7 +13,7 @@
     3.4          area = delegation.area
     3.5        end
     3.6        if not area then
     3.7 -        ui.field.text{ value = _"Global delegation" }
     3.8 +        ui.field.text{ value = _"Unit delegation" }
     3.9        end
    3.10        if area then
    3.11          ui.link{
     4.1 --- a/app/main/delegation/_show_box.lua	Fri Dec 30 03:11:57 2011 +0100
     4.2 +++ b/app/main/delegation/_show_box.lua	Fri Dec 30 03:13:10 2011 +0100
     4.3 @@ -1,12 +1,12 @@
     4.4 -function change_delegation(scope, area_id, issue, delegation, initiative_id)
     4.5 +function change_delegation(scope, unit_id, area_id, issue, delegation, initiative_id)
     4.6    local image
     4.7    local text
     4.8 -  if scope == "global" and delegation then
     4.9 +  if scope == "unit" and delegation and delegation.unit_id then
    4.10      image = { static = "icons/16/table_go.png" }
    4.11 -    text = _"Change global delegation"
    4.12 -  elseif scope == "global" and not delegation then
    4.13 +    text = _"Change unit delegation"
    4.14 +  elseif scope == "unit" and not (delegation and delegation.unit_id) then
    4.15      image = { static = "icons/16/table_go.png" }
    4.16 -    text = _"Set global delegation"
    4.17 +    text = _"Set unit delegation"
    4.18    elseif scope == "area" and delegation and delegation.area_id then
    4.19      image = { static = "icons/16/table_go.png" }
    4.20      text = _"Change area delegation"
    4.21 @@ -35,7 +35,8 @@
    4.22          params = {
    4.23            issue_id = issue and issue.id or nil,
    4.24            initiative_id = initiative_id or nil,
    4.25 -          area_id = area_id
    4.26 +          area_id = area_id,
    4.27 +          unit_id = unit_id
    4.28          },
    4.29        }
    4.30        if delegation then
    4.31 @@ -44,7 +45,7 @@
    4.32            text   = _"Revoke",
    4.33            module = "delegation",
    4.34            action = "update",
    4.35 -          params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true },
    4.36 +          params = { issue_id = delegation.issue_id, area_id = delegation.area_id, unit_id = delegation.unit_id, delete = true },
    4.37            routing = {
    4.38              default = {
    4.39                mode = "redirect",
    4.40 @@ -61,11 +62,14 @@
    4.41  end
    4.42  
    4.43  local delegation
    4.44 +local unit_id
    4.45  local area_id
    4.46  local issue_id
    4.47  local initiative_id
    4.48  
    4.49 -local scope = "global"
    4.50 +local scope = "unit"
    4.51 +
    4.52 +unit_id = param.get("unit_id", atom.integer)
    4.53  
    4.54  if param.get("initiative_id", atom.integer) then
    4.55    initiative_id = param.get("initiative_id", atom.integer)
    4.56 @@ -90,16 +94,16 @@
    4.57  
    4.58  if issue_id then
    4.59    issue = Issue:by_id(issue_id)
    4.60 -  delegation = Delegation:by_pk(app.session.member.id, nil, issue_id)
    4.61 +  delegation = Delegation:by_pk(app.session.member.id, nil, nil, issue_id)
    4.62    if not delegation then
    4.63 -    delegation = Delegation:by_pk(app.session.member.id, issue.area_id)
    4.64 +    delegation = Delegation:by_pk(app.session.member.id, nil, issue.area_id)
    4.65    end
    4.66  elseif area_id then
    4.67 -  delegation = Delegation:by_pk(app.session.member.id, area_id)
    4.68 +  delegation = Delegation:by_pk(app.session.member.id, nil, area_id)
    4.69  end
    4.70  
    4.71  if not delegation then
    4.72 -  delegation = Delegation:by_pk(app.session.member.id)
    4.73 +  delegation = Delegation:by_pk(app.session.member.id, unit_id)
    4.74  end
    4.75  
    4.76  
    4.77 @@ -126,7 +130,7 @@
    4.78                elseif delegation.area_id then
    4.79                  slot.put(_"Area delegation active")
    4.80                else
    4.81 -                slot.put(_"Global delegation active")
    4.82 +                slot.put(_"Unit delegation active")
    4.83                end
    4.84              else
    4.85                ui.image{
    4.86 @@ -164,7 +168,7 @@
    4.87                :exec()
    4.88      
    4.89              if not issue or (issue.state ~= "finished" and issue.state ~= "cancelled") then
    4.90 -              change_delegation(scope, area_id, issue, delegation, initiative_id)
    4.91 +              change_delegation(scope, unit_id, area_id, issue, delegation, initiative_id)
    4.92              end
    4.93  
    4.94              for i, record in ipairs(delegation_chain) do
    4.95 @@ -188,8 +192,8 @@
    4.96                      ui.container{
    4.97                        attr = { class = "delegation_scope" .. (overridden and " delegation_scope_overridden" or "") },
    4.98                        content = function()
    4.99 -                        if record.scope_in == "global" then
   4.100 -                          slot.put(_"Global delegation")
   4.101 +                        if record.scope_in == "unit" then
   4.102 +                          slot.put(_"Unit delegation")
   4.103                          elseif record.scope_in == "area" then
   4.104                            slot.put(_"Area delegation")
   4.105                          elseif record.scope_in == "issue" then
   4.106 @@ -225,6 +229,6 @@
   4.107        end
   4.108      }
   4.109    else
   4.110 -    change_delegation(scope, area_id, issue, nil, initiative_id)
   4.111 +    change_delegation(scope, unit_id, area_id, issue, nil, initiative_id)
   4.112    end
   4.113  end)
     5.1 --- a/app/main/delegation/new.lua	Fri Dec 30 03:11:57 2011 +0100
     5.2 +++ b/app/main/delegation/new.lua	Fri Dec 30 03:13:10 2011 +0100
     5.3 @@ -1,3 +1,9 @@
     5.4 +local unit = Unit:by_id(param.get("unit_id", atom.integer))
     5.5 +if unit then
     5.6 +  slot.put_into("title", encode.html(_"Set unit delegation"))
     5.7 +  util.help("delegation.new.unit")
     5.8 +end
     5.9 +
    5.10  local area = Area:by_id(param.get("area_id", atom.integer))
    5.11  if area then
    5.12    slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name)))
    5.13 @@ -12,11 +18,6 @@
    5.14  
    5.15  local initiative = Initiative:by_id(param.get("initiative_id", atom.integer))
    5.16  
    5.17 -if not area and not issue then
    5.18 -  slot.put_into("title", encode.html(_"Set global delegation"))
    5.19 -  util.help("delegation.new.global")
    5.20 -end
    5.21 -
    5.22  slot.select("actions", function()
    5.23    if issue then
    5.24      ui.link{
    5.25 @@ -61,6 +62,7 @@
    5.26    module = "delegation",
    5.27    action = "update",
    5.28    params = {
    5.29 +    unit_id = unit and unit.id or nil,
    5.30      area_id = area and area.id or nil,
    5.31      issue_id = issue and issue.id or nil,
    5.32    },
    5.33 @@ -78,44 +80,44 @@
    5.34      if issue then
    5.35        local delegate_name = ""
    5.36        local scope = "no delegation set"
    5.37 -      local area_delegation = Delegation:by_pk(app.session.member_id, issue.area_id)
    5.38 +      local area_delegation = Delegation:by_pk(app.session.member_id, nil, issue.area_id)
    5.39        if area_delegation then
    5.40          delegate_name = area_delegation.trustee and area_delegation.trustee.name or _"abandoned"
    5.41          scope = _"area"
    5.42        else
    5.43 -      local global_delegation = Delegation:by_pk(app.session.member_id)
    5.44 -      if global_delegation then
    5.45 -        delegate_name = global_delegation.trustee.name
    5.46 -        scope = _"global"
    5.47 +        local unit_delegation = Delegation:by_pk(app.session.member_id, issue.area.unit_id)
    5.48 +        if unit_delegation then
    5.49 +          delegate_name = unit_delegation.trustee.name
    5.50 +          scope = _"unit"
    5.51 +        end
    5.52        end
    5.53 -    end
    5.54        records = {
    5.55          {
    5.56            id = -1,
    5.57 -          name = _("Apply global or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
    5.58 +          name = _("Apply unit or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
    5.59          },
    5.60          {
    5.61            id = 0,
    5.62 -          name = _"Abandon global and area delegations for this issue"
    5.63 +          name = _"Abandon unit and area delegations for this issue"
    5.64          },
    5.65  
    5.66        }
    5.67      elseif area then
    5.68        local delegate_name = ""
    5.69        local scope = "no delegation set"
    5.70 -      local global_delegation = Delegation:by_pk(app.session.member_id)
    5.71 -      if global_delegation then
    5.72 -        delegate_name = global_delegation.trustee.name
    5.73 -        scope = _"global"
    5.74 +      local unit_delegation = Delegation:by_pk(app.session.member_id, area.unit_id)
    5.75 +      if unit_delegation then
    5.76 +        delegate_name = unit_delegation.trustee.name
    5.77 +        scope = _"unit"
    5.78        end
    5.79        records = {
    5.80          {
    5.81            id = -1,
    5.82 -          name = _("Apply global delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
    5.83 +          name = _("Apply unit delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
    5.84          },
    5.85          {
    5.86            id = 0,
    5.87 -          name = _"Abandon global delegation for this area"
    5.88 +          name = _"Abandon unit delegation for this area"
    5.89          }
    5.90        }
    5.91  
     6.1 --- a/app/main/index/index.lua	Fri Dec 30 03:11:57 2011 +0100
     6.2 +++ b/app/main/index/index.lua	Fri Dec 30 03:13:10 2011 +0100
     6.3 @@ -68,10 +68,6 @@
     6.4        module = "member",
     6.5        view = "edit_images"
     6.6      }
     6.7 -    execute.view{
     6.8 -      module = "delegation",
     6.9 -      view = "_show_box"
    6.10 -    }
    6.11      ui.link{
    6.12        content = function()
    6.13            ui.image{ static = "icons/16/wrench.png" }
     7.1 --- a/model/delegation.lua	Fri Dec 30 03:11:57 2011 +0100
     7.2 +++ b/model/delegation.lua	Fri Dec 30 03:13:10 2011 +0100
     7.3 @@ -33,9 +33,14 @@
     7.4    ref           = 'issue',
     7.5  }
     7.6  
     7.7 -function Delegation:by_pk(truster_id, area_id, issue_id)
     7.8 +function Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
     7.9    local selector = self:new_selector():optional_object_mode()
    7.10    selector:add_where{ "truster_id = ?", truster_id }
    7.11 +  if unit_id then
    7.12 +    selector:add_where{ "unit_id = ?",    unit_id }
    7.13 +  else
    7.14 +    selector:add_where("unit_id ISNULL")
    7.15 +  end
    7.16    if area_id then
    7.17      selector:add_where{ "area_id = ?",    area_id }
    7.18    else
    7.19 @@ -47,4 +52,4 @@
    7.20      selector:add_where("issue_id ISNULL ")
    7.21    end
    7.22    return selector:exec()
    7.23 -end
    7.24 \ No newline at end of file
    7.25 +end

Impressum / About Us