liquid_feedback_frontend

view app/main/delegation/_action/update.lua @ 281:b77e6a17ca77

Check unit voting right where neccessary, hide action buttons for units without voting right
author bsw
date Thu Feb 16 15:01:49 2012 +0100 (2012-02-16)
parents fecd4c13054a
children a72a389399fc
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 if param.get("delete") or trustee_id == -1 then
17 if delegation then
19 delegation:destroy()
21 --[[
22 if issue_id then
23 slot.put_into("notice", _"Your delegation for this issue has been deleted.")
24 elseif area_id then
25 slot.put_into("notice", _"Your delegation for this area has been deleted.")
26 else
27 slot.put_into("notice", _"Your delegation for this unit has been deleted.")
28 end
29 --]]
30 end
32 else
34 local check_unit_id
35 if unit_id then
36 check_unit_id = unit_id
37 elseif area_id then
38 local area = Area:by_id(area_id)
39 check_unit_id = area.unit_id
40 else
41 local issue = Issue:by_id(issue_id)
42 local area = Area:by_id(issue.area_id)
43 check_unit_id = area.unit_id
44 end
46 if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
47 error("access denied")
48 end
50 local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
52 if not delegation then
53 delegation = Delegation:new()
54 delegation.truster_id = truster_id
55 delegation.unit_id = unit_id
56 delegation.area_id = area_id
57 delegation.issue_id = issue_id
58 if issue_id then
59 delegation.scope = "issue"
60 elseif area_id then
61 delegation.scope = "area"
62 elseif unit_id then
63 delegation.scope = "unit"
64 end
65 end
66 if trustee_id == 0 then
67 delegation.trustee_id = nil
68 else
69 delegation.trustee_id = trustee_id
70 end
72 delegation:save()
73 --[[
74 if issue_id then
75 slot.put_into("notice", _"Your delegation for this issue has been updated.")
76 elseif area_id then
77 slot.put_into("notice", _"Your delegation for this area has been updated.")
78 else
79 slot.put_into("notice", _"Your delegation for this unit has been updated.")
80 end
81 --]]
82 end

Impressum / About Us