liquid_feedback_frontend
view app/main/delegation/_action/update.lua @ 1420:09f50a44cb7d
Removed not needed code
| author | bsw | 
|---|---|
| date | Thu Aug 30 10:57:39 2018 +0200 (2018-08-30) | 
| parents | 32cc544d5a5b | 
| children | 72442abafb3c | 
 line source
     1 if config.disable_delegations then
     2   return
     3 end
     5 local truster_id = app.session.member.id
     7 local trustee_id = param.get("trustee_id", atom.integer)
     9 local unit_id = param.get("unit_id", atom.integer)
    11 local area_id = param.get("area_id", atom.integer)
    13 local issue_id = param.get("issue_id", atom.integer)
    15 local initiative_id = param.get("initiative_id", atom.integer)
    17 if issue_id then 
    18   area_id = nil
    19 end
    21 local preview = param.get("preview") 
    23 if preview == "1" then
    24   request.redirect{ module = "delegation", view = "show", params = {
    25     unit_id = unit_id, area_id = area_id, issue_id = issue_id, initiative_id = initiative_id, preview_trustee_id = trustee_id
    26   } }
    27   return
    28 end
    30 local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
    33 if param.get("delete") or trustee_id == -1 then
    35   if delegation then
    36     delegation:destroy()
    37   end
    39 else
    41   local trustee
    43   if trustee_id then
    44     trustee = Member:by_id(trustee_id)
    45   end
    47   local check_unit_id
    48   if unit_id then
    49     check_unit_id = unit_id
    50   elseif area_id then
    51     local area = Area:by_id(area_id)
    52     check_unit_id = area.unit_id
    53   else
    54     local issue = Issue:by_id(issue_id)
    55     local area = Area:by_id(issue.area_id)
    56     check_unit_id = area.unit_id
    57   end
    59   if trustee and not trustee:has_voting_right_for_unit_id(check_unit_id) then
    60     slot.put_into("error", _"Trustee has no voting right in this unit")
    61     return false
    62   end
    64   if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
    65     return execute.view { module = "index", view = "403" }
    66   end
    68   if not delegation then
    69     delegation = Delegation:new()
    70     delegation.truster_id = truster_id
    71     delegation.unit_id    = unit_id
    72     delegation.area_id    = area_id
    73     delegation.issue_id   = issue_id
    74     if issue_id then
    75       delegation.scope = "issue"
    76     elseif area_id then
    77       delegation.scope = "area"
    78     elseif unit_id then
    79       delegation.scope = "unit"
    80     end
    81   end
    82   if trustee_id == 0 then
    83     delegation.trustee_id = nil
    84   else
    85     delegation.trustee_id = trustee_id
    86   end
    88   delegation:save()
    90 end
