liquid_feedback_frontend
view app/main/delegation/_action/update.lua @ 298:724ac69b7c97
Fix voting_right_for_unit_id argument for member selector builder
author | bsw |
---|---|
date | Sat Feb 25 22:27:03 2012 +0100 (2012-02-25) |
parents | d39fa6c0ff0b |
children | cb9ccdd024f2 |
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 trustee = Member:by_id(trustee_id)
39 local check_unit_id
40 if unit_id then
41 check_unit_id = unit_id
42 elseif area_id then
43 local area = Area:by_id(area_id)
44 check_unit_id = area.unit_id
45 else
46 local issue = Issue:by_id(issue_id)
47 local area = Area:by_id(issue.area_id)
48 check_unit_id = area.unit_id
49 end
51 if not trustee:has_voting_right_for_unit_id(check_unit_id) then
52 slot.put_into("error", _"Trustee has no voting right in this unit")
53 return false
54 end
56 if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
57 error("access denied")
58 end
60 if not delegation then
61 delegation = Delegation:new()
62 delegation.truster_id = truster_id
63 delegation.unit_id = unit_id
64 delegation.area_id = area_id
65 delegation.issue_id = issue_id
66 if issue_id then
67 delegation.scope = "issue"
68 elseif area_id then
69 delegation.scope = "area"
70 elseif unit_id then
71 delegation.scope = "unit"
72 end
73 end
74 if trustee_id == 0 then
75 delegation.trustee_id = nil
76 else
77 delegation.trustee_id = trustee_id
78 end
80 delegation:save()
81 --[[
82 if issue_id then
83 slot.put_into("notice", _"Your delegation for this issue has been updated.")
84 elseif area_id then
85 slot.put_into("notice", _"Your delegation for this area has been updated.")
86 else
87 slot.put_into("notice", _"Your delegation for this unit has been updated.")
88 end
89 --]]
90 end