liquid_feedback_frontend

view app/main/delegation/_action/update.lua @ 929:403e8c211592

Going to version 2.1.2
author bsw
date Sat Oct 20 17:21:04 2012 +0200 (2012-10-20)
parents 5650f8163a29
children 32cc544d5a5b
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 local initiative_id = param.get("initiative_id", atom.integer)
13 if issue_id then
14 area_id = nil
15 end
17 local preview = param.get("preview")
19 if preview == "1" then
20 request.redirect{ module = "delegation", view = "show", params = {
21 unit_id = unit_id, area_id = area_id, issue_id = issue_id, initiative_id = initiative_id, preview_trustee_id = trustee_id
22 } }
23 return
24 end
26 local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
29 if param.get("delete") or trustee_id == -1 then
31 if delegation then
32 delegation:destroy()
33 end
35 else
37 local trustee
39 if trustee_id then
40 trustee = Member:by_id(trustee_id)
41 end
43 local check_unit_id
44 if unit_id then
45 check_unit_id = unit_id
46 elseif area_id then
47 local area = Area:by_id(area_id)
48 check_unit_id = area.unit_id
49 else
50 local issue = Issue:by_id(issue_id)
51 local area = Area:by_id(issue.area_id)
52 check_unit_id = area.unit_id
53 end
55 if trustee and not trustee:has_voting_right_for_unit_id(check_unit_id) then
56 slot.put_into("error", _"Trustee has no voting right in this unit")
57 return false
58 end
60 if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
61 error("access denied")
62 end
64 if not delegation then
65 delegation = Delegation:new()
66 delegation.truster_id = truster_id
67 delegation.unit_id = unit_id
68 delegation.area_id = area_id
69 delegation.issue_id = issue_id
70 if issue_id then
71 delegation.scope = "issue"
72 elseif area_id then
73 delegation.scope = "area"
74 elseif unit_id then
75 delegation.scope = "unit"
76 end
77 end
78 if trustee_id == 0 then
79 delegation.trustee_id = nil
80 else
81 delegation.trustee_id = trustee_id
82 end
84 delegation:save()
86 end

Impressum / About Us