liquid_feedback_frontend
view app/main/delegation/_action/update.lua @ 264:1b8d51e21614
More unit support added
author | bsw |
---|---|
date | Tue Feb 07 18:32:18 2012 +0100 (2012-02-07) |
parents | e3613831cd1e |
children | fecd4c13054a |
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)
17 if param.get("delete") or trustee_id == -1 then
19 if delegation then
21 delegation:destroy()
23 if issue_id then
24 slot.put_into("notice", _"Your delegation for this issue has been deleted.")
25 elseif area_id then
26 slot.put_into("notice", _"Your delegation for this area has been deleted.")
27 else
28 slot.put_into("notice", _"Your delegation for this unit has been deleted.")
29 end
31 end
33 else
35 if not delegation then
36 delegation = Delegation:new()
37 delegation.truster_id = truster_id
38 delegation.unit_id = unit_id
39 delegation.area_id = area_id
40 delegation.issue_id = issue_id
41 if issue_id then
42 delegation.scope = "issue"
43 elseif area_id then
44 delegation.scope = "area"
45 elseif unit_id then
46 delegation.scope = "unit"
47 end
48 end
49 if trustee_id == 0 then
50 delegation.trustee_id = nil
51 else
52 delegation.trustee_id = trustee_id
53 end
55 delegation:save()
57 if issue_id then
58 slot.put_into("notice", _"Your delegation for this issue has been updated.")
59 elseif area_id then
60 slot.put_into("notice", _"Your delegation for this area has been updated.")
61 else
62 slot.put_into("notice", _"Your delegation for this unit has been updated.")
63 end
65 end