liquid_feedback_frontend

annotate app/main/delegation/_action/update.lua @ 575:5650f8163a29

Fixed errors from delegation dialog
author bsw
date Wed Jun 20 00:22:53 2012 +0200 (2012-06-20)
parents 5ca9de94cb13
children 403e8c211592
rev   line source
bsw/jbe@0 1 local truster_id = app.session.member.id
bsw/jbe@0 2
bsw/jbe@0 3 local trustee_id = param.get("trustee_id", atom.integer)
bsw/jbe@0 4
bsw@248 5 local unit_id = param.get("unit_id", atom.integer)
bsw@248 6
bsw/jbe@0 7 local area_id = param.get("area_id", atom.integer)
bsw/jbe@0 8
bsw/jbe@0 9 local issue_id = param.get("issue_id", atom.integer)
bsw/jbe@0 10
bsw@575 11 local initiative_id = param.get("initiative_id", atom.integer)
bsw@575 12
bsw/jbe@0 13 if issue_id then
bsw/jbe@0 14 area_id = nil
bsw/jbe@0 15 end
bsw/jbe@0 16
bsw@529 17 local preview = param.get("preview")
bsw@529 18
bsw@529 19 if preview == "1" then
bsw@529 20 request.redirect{ module = "delegation", view = "show", params = {
bsw@575 21 unit_id = unit_id, area_id = area_id, issue_id = issue_id, initiative_id = initiative_id, preview_trustee_id = trustee_id
bsw@529 22 } }
bsw@529 23 return
bsw@529 24 end
bsw@529 25
bsw@529 26
bsw@293 27 local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
bsw@293 28
bsw@293 29
bsw/jbe@4 30 if param.get("delete") or trustee_id == -1 then
bsw/jbe@0 31
bsw/jbe@0 32 if delegation then
bsw/jbe@0 33 delegation:destroy()
bsw/jbe@0 34 end
bsw/jbe@5 35
bsw/jbe@0 36 else
bsw@296 37
bsw@300 38 local trustee
bsw@300 39
bsw@300 40 if trustee_id then
bsw@300 41 trustee = Member:by_id(trustee_id)
bsw@300 42 end
bsw/jbe@0 43
bsw@281 44 local check_unit_id
bsw@281 45 if unit_id then
bsw@281 46 check_unit_id = unit_id
bsw@281 47 elseif area_id then
bsw@281 48 local area = Area:by_id(area_id)
bsw@281 49 check_unit_id = area.unit_id
bsw@281 50 else
bsw@281 51 local issue = Issue:by_id(issue_id)
bsw@281 52 local area = Area:by_id(issue.area_id)
bsw@281 53 check_unit_id = area.unit_id
bsw@281 54 end
bsw@296 55
bsw@300 56 if trustee and not trustee:has_voting_right_for_unit_id(check_unit_id) then
bsw@296 57 slot.put_into("error", _"Trustee has no voting right in this unit")
bsw@296 58 return false
bsw@296 59 end
bsw@281 60
bsw@281 61 if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
bsw@281 62 error("access denied")
bsw@281 63 end
bsw@281 64
bsw/jbe@0 65 if not delegation then
bsw/jbe@0 66 delegation = Delegation:new()
bsw/jbe@0 67 delegation.truster_id = truster_id
bsw@248 68 delegation.unit_id = unit_id
bsw/jbe@0 69 delegation.area_id = area_id
bsw/jbe@0 70 delegation.issue_id = issue_id
bsw/jbe@5 71 if issue_id then
bsw/jbe@5 72 delegation.scope = "issue"
bsw/jbe@5 73 elseif area_id then
bsw/jbe@5 74 delegation.scope = "area"
bsw@248 75 elseif unit_id then
bsw@248 76 delegation.scope = "unit"
bsw/jbe@5 77 end
bsw/jbe@0 78 end
bsw@180 79 if trustee_id == 0 then
bsw@180 80 delegation.trustee_id = nil
bsw@180 81 else
bsw@180 82 delegation.trustee_id = trustee_id
bsw@180 83 end
bsw/jbe@0 84
bsw/jbe@0 85 delegation:save()
bsw@529 86
bsw/jbe@0 87 end
bsw/jbe@0 88

Impressum / About Us