liquid_feedback_frontend
view app/main/delegation/_action/update.lua @ 335:4608babc79f2
Correctly interpret initiative.winner when showing approved information in initiative view
| author | bsw | 
|---|---|
| date | Tue Feb 28 18:46:10 2012 +0100 (2012-02-28) | 
| parents | cb9ccdd024f2 | 
| children | 5ca9de94cb13 | 
 line source
     1 local truster_id = app.session.member.id
     3 local trustee_id = param.get("trustee_id", atom.integer)
     5 local unit_id = param.get("unit_id", atom.integer)
     7 local area_id = param.get("area_id", atom.integer)
     9 local issue_id = param.get("issue_id", atom.integer)
    11 if issue_id then 
    12   area_id = nil
    13 end
    15 local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
    18 if param.get("delete") or trustee_id == -1 then
    20   if delegation then
    22     delegation:destroy()
    24 --[[
    25     if issue_id then
    26       slot.put_into("notice", _"Your delegation for this issue has been deleted.")
    27     elseif area_id then
    28       slot.put_into("notice", _"Your delegation for this area has been deleted.")
    29     else
    30       slot.put_into("notice", _"Your delegation for this unit has been deleted.")
    31     end
    32 --]]
    33   end
    35 else
    37   local trustee
    39   if trustee_id then
    40     trustee = Member:by_id(trustee_id)
    41   end
    43   local check_unit_id
    44   if unit_id then
    45     check_unit_id = unit_id
    46   elseif area_id then
    47     local area = Area:by_id(area_id)
    48     check_unit_id = area.unit_id
    49   else
    50     local issue = Issue:by_id(issue_id)
    51     local area = Area:by_id(issue.area_id)
    52     check_unit_id = area.unit_id
    53   end
    55   if trustee and not trustee:has_voting_right_for_unit_id(check_unit_id) then
    56     slot.put_into("error", _"Trustee has no voting right in this unit")
    57     return false
    58   end
    60   if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
    61     error("access denied")
    62   end
    64   if not delegation then
    65     delegation = Delegation:new()
    66     delegation.truster_id = truster_id
    67     delegation.unit_id    = unit_id
    68     delegation.area_id    = area_id
    69     delegation.issue_id   = issue_id
    70     if issue_id then
    71       delegation.scope = "issue"
    72     elseif area_id then
    73       delegation.scope = "area"
    74     elseif unit_id then
    75       delegation.scope = "unit"
    76     end
    77   end
    78   if trustee_id == 0 then
    79     delegation.trustee_id = nil
    80   else
    81     delegation.trustee_id = trustee_id
    82   end
    84   delegation:save()
    85 --[[
    86   if issue_id then
    87     slot.put_into("notice", _"Your delegation for this issue has been updated.")
    88   elseif area_id then
    89     slot.put_into("notice", _"Your delegation for this area has been updated.")
    90   else
    91     slot.put_into("notice", _"Your delegation for this unit has been updated.")
    92   end
    93 --]]
    94 end
