liquid_feedback_frontend
view app/main/delegation/_action/update.lua @ 217:73dbc9e2bfd4
Cummulative patch for enhancements at next generation frontend
author | bsw |
---|---|
date | Sat Mar 12 19:22:50 2011 +0100 (2011-03-12) |
parents | 02aacb3dffe0 |
children |
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 elseif area_id then
14 unit_id = nil
15 end
17 local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
19 if param.get("delete") or trustee_id == -1 then
21 if delegation then
23 delegation:destroy()
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 elseif unit_id then
30 slot.put_into("notice", _"Your delegation for this unit has been deleted.")
31 else
32 error("shouldn't happen")
33 end
35 end
37 else
39 if not delegation then
40 delegation = Delegation:new()
41 delegation.truster_id = truster_id
42 delegation.unit_id = unit_id
43 delegation.area_id = area_id
44 delegation.issue_id = issue_id
45 if issue_id then
46 delegation.scope = "issue"
47 elseif area_id then
48 delegation.scope = "area"
49 elseif unit_id then
50 delegation.scope = "unit"
51 else
52 error("should'nt happen")
53 end
54 end
55 if trustee_id == 0 then
56 delegation.trustee_id = nil
57 else
58 delegation.trustee_id = trustee_id
59 end
61 delegation:save()
63 if issue_id then
64 slot.put_into("notice", _"Your delegation for this issue has been updated.")
65 elseif area_id then
66 slot.put_into("notice", _"Your delegation for this area has been updated.")
67 elseif unit_id then
68 slot.put_into("notice", _"Your delegation for this unit has been updated.")
69 else
70 error("shouldn't happen")
71 end
73 end