liquid_feedback_frontend

view app/main/delegation/_action/update.lua @ 547:57a261a81c5a

Added preloading to issue list
author bsw
date Tue May 29 20:43:27 2012 +0200 (2012-05-29)
parents 5ca9de94cb13
children 5650f8163a29
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 preview = param.get("preview")
17 if preview == "1" then
18 request.redirect{ module = "delegation", view = "show", params = {
19 unit_id = unit_id, area_id = area_id, issue_id = issue_id, preview_trustee_id = trustee_id
20 } }
21 return
22 end
25 local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
28 if param.get("delete") or trustee_id == -1 then
30 if delegation then
31 delegation:destroy()
32 end
34 else
36 local trustee
38 if trustee_id then
39 trustee = Member:by_id(trustee_id)
40 end
42 local check_unit_id
43 if unit_id then
44 check_unit_id = unit_id
45 elseif area_id then
46 local area = Area:by_id(area_id)
47 check_unit_id = area.unit_id
48 else
49 local issue = Issue:by_id(issue_id)
50 local area = Area:by_id(issue.area_id)
51 check_unit_id = area.unit_id
52 end
54 if trustee and not trustee:has_voting_right_for_unit_id(check_unit_id) then
55 slot.put_into("error", _"Trustee has no voting right in this unit")
56 return false
57 end
59 if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
60 error("access denied")
61 end
63 if not delegation then
64 delegation = Delegation:new()
65 delegation.truster_id = truster_id
66 delegation.unit_id = unit_id
67 delegation.area_id = area_id
68 delegation.issue_id = issue_id
69 if issue_id then
70 delegation.scope = "issue"
71 elseif area_id then
72 delegation.scope = "area"
73 elseif unit_id then
74 delegation.scope = "unit"
75 end
76 end
77 if trustee_id == 0 then
78 delegation.trustee_id = nil
79 else
80 delegation.trustee_id = trustee_id
81 end
83 delegation:save()
85 end

Impressum / About Us