liquid_feedback_frontend

diff app/main/delegation/_action/update.lua @ 0:3bfb2fcf7ab9

Version alpha1
author bsw/jbe
date Wed Nov 18 12:00:00 2009 +0100 (2009-11-18)
parents
children 80c215dbf076
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/delegation/_action/update.lua	Wed Nov 18 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +local truster_id = app.session.member.id
     1.5 +
     1.6 +local trustee_id = param.get("trustee_id", atom.integer)
     1.7 +
     1.8 +local area_id = param.get("area_id", atom.integer)
     1.9 +
    1.10 +local issue_id = param.get("issue_id", atom.integer)
    1.11 +
    1.12 +if issue_id then 
    1.13 +  area_id = nil
    1.14 +end
    1.15 +
    1.16 +local delegation = Delegation:by_pk(truster_id, area_id, issue_id)
    1.17 +
    1.18 +if param.get("delete") then
    1.19 +
    1.20 +  if delegation then
    1.21 +  
    1.22 +    delegation:destroy()
    1.23 +  
    1.24 +    if issue_id then
    1.25 +      slot.put_into("notice", _"Your delegation for this issue has been deleted.")
    1.26 +    elseif area_id then
    1.27 +      slot.put_into("notice", _"Your delegation for this area has been deleted.")
    1.28 +    else
    1.29 +      slot.put_into("notice", _"Your global delegation has been deleted.")
    1.30 +    end
    1.31 +
    1.32 +  end
    1.33 +  
    1.34 +else
    1.35 +
    1.36 +  if not delegation then
    1.37 +    delegation = Delegation:new()
    1.38 +    delegation.truster_id = truster_id
    1.39 +    delegation.area_id    = area_id
    1.40 +    delegation.issue_id   = issue_id
    1.41 +  end
    1.42 +
    1.43 +  delegation.trustee_id = trustee_id
    1.44 +
    1.45 +  delegation:save()
    1.46 +
    1.47 +  if issue_id then
    1.48 +    slot.put_into("notice", _"Your delegation for this issue has been updated.")
    1.49 +  elseif area_id then
    1.50 +    slot.put_into("notice", _"Your delegation for this area has been updated.")
    1.51 +  else
    1.52 +    slot.put_into("notice", _"Your global delegation has been updated.")
    1.53 +  end
    1.54 +
    1.55 +end
    1.56 +

Impressum / About Us