liquid_feedback_frontend
view app/main/delegation/_action/update.lua @ 293:a72a389399fc
Fixed to issues with modified delegation code
author | bsw |
---|---|
date | Sat Feb 25 20:36:31 2012 +0100 (2012-02-25) |
parents | b77e6a17ca77 |
children | d39fa6c0ff0b |
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 check_unit_id
38 if unit_id then
39 check_unit_id = unit_id
40 elseif area_id then
41 local area = Area:by_id(area_id)
42 check_unit_id = area.unit_id
43 else
44 local issue = Issue:by_id(issue_id)
45 local area = Area:by_id(issue.area_id)
46 check_unit_id = area.unit_id
47 end
49 if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
50 error("access denied")
51 end
53 if not delegation then
54 delegation = Delegation:new()
55 delegation.truster_id = truster_id
56 delegation.unit_id = unit_id
57 delegation.area_id = area_id
58 delegation.issue_id = issue_id
59 if issue_id then
60 delegation.scope = "issue"
61 elseif area_id then
62 delegation.scope = "area"
63 elseif unit_id then
64 delegation.scope = "unit"
65 end
66 end
67 if trustee_id == 0 then
68 delegation.trustee_id = nil
69 else
70 delegation.trustee_id = trustee_id
71 end
73 delegation:save()
74 --[[
75 if issue_id then
76 slot.put_into("notice", _"Your delegation for this issue has been updated.")
77 elseif area_id then
78 slot.put_into("notice", _"Your delegation for this area has been updated.")
79 else
80 slot.put_into("notice", _"Your delegation for this unit has been updated.")
81 end
82 --]]
83 end