liquid_feedback_frontend

view app/main/delegation/_action/update.lua @ 777:e571c73a21d9

Added tag translate for changeset 4712d09ace10
author bsw
date Thu Jun 28 23:59:08 2012 +0200 (2012-06-28)
parents 5650f8163a29
children 403e8c211592
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
27 local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
30 if param.get("delete") or trustee_id == -1 then
32 if delegation then
33 delegation:destroy()
34 end
36 else
38 local trustee
40 if trustee_id then
41 trustee = Member:by_id(trustee_id)
42 end
44 local check_unit_id
45 if unit_id then
46 check_unit_id = unit_id
47 elseif area_id then
48 local area = Area:by_id(area_id)
49 check_unit_id = area.unit_id
50 else
51 local issue = Issue:by_id(issue_id)
52 local area = Area:by_id(issue.area_id)
53 check_unit_id = area.unit_id
54 end
56 if trustee and not trustee:has_voting_right_for_unit_id(check_unit_id) then
57 slot.put_into("error", _"Trustee has no voting right in this unit")
58 return false
59 end
61 if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
62 error("access denied")
63 end
65 if not delegation then
66 delegation = Delegation:new()
67 delegation.truster_id = truster_id
68 delegation.unit_id = unit_id
69 delegation.area_id = area_id
70 delegation.issue_id = issue_id
71 if issue_id then
72 delegation.scope = "issue"
73 elseif area_id then
74 delegation.scope = "area"
75 elseif unit_id then
76 delegation.scope = "unit"
77 end
78 end
79 if trustee_id == 0 then
80 delegation.trustee_id = nil
81 else
82 delegation.trustee_id = trustee_id
83 end
85 delegation:save()
87 end

Impressum / About Us