liquid_feedback_frontend

annotate 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
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/jbe@0 11 if issue_id then
bsw/jbe@0 12 area_id = nil
bsw/jbe@0 13 end
bsw/jbe@0 14
bsw/jbe@4 15 if param.get("delete") or trustee_id == -1 then
bsw/jbe@0 16
bsw/jbe@0 17 if delegation then
bsw/jbe@5 18
bsw/jbe@0 19 delegation:destroy()
bsw/jbe@5 20
bsw@278 21 --[[
bsw/jbe@0 22 if issue_id then
bsw/jbe@0 23 slot.put_into("notice", _"Your delegation for this issue has been deleted.")
bsw/jbe@0 24 elseif area_id then
bsw/jbe@0 25 slot.put_into("notice", _"Your delegation for this area has been deleted.")
bsw/jbe@0 26 else
bsw@248 27 slot.put_into("notice", _"Your delegation for this unit has been deleted.")
bsw/jbe@0 28 end
bsw@278 29 --]]
bsw/jbe@0 30 end
bsw/jbe@5 31
bsw/jbe@0 32 else
bsw/jbe@0 33
bsw@281 34 local check_unit_id
bsw@281 35 if unit_id then
bsw@281 36 check_unit_id = unit_id
bsw@281 37 elseif area_id then
bsw@281 38 local area = Area:by_id(area_id)
bsw@281 39 check_unit_id = area.unit_id
bsw@281 40 else
bsw@281 41 local issue = Issue:by_id(issue_id)
bsw@281 42 local area = Area:by_id(issue.area_id)
bsw@281 43 check_unit_id = area.unit_id
bsw@281 44 end
bsw@281 45
bsw@281 46 if not app.session.member:has_voting_right_for_unit_id(check_unit_id) then
bsw@281 47 error("access denied")
bsw@281 48 end
bsw@281 49
bsw@281 50 local delegation = Delegation:by_pk(truster_id, unit_id, area_id, issue_id)
bsw@281 51
bsw/jbe@0 52 if not delegation then
bsw/jbe@0 53 delegation = Delegation:new()
bsw/jbe@0 54 delegation.truster_id = truster_id
bsw@248 55 delegation.unit_id = unit_id
bsw/jbe@0 56 delegation.area_id = area_id
bsw/jbe@0 57 delegation.issue_id = issue_id
bsw/jbe@5 58 if issue_id then
bsw/jbe@5 59 delegation.scope = "issue"
bsw/jbe@5 60 elseif area_id then
bsw/jbe@5 61 delegation.scope = "area"
bsw@248 62 elseif unit_id then
bsw@248 63 delegation.scope = "unit"
bsw/jbe@5 64 end
bsw/jbe@0 65 end
bsw@180 66 if trustee_id == 0 then
bsw@180 67 delegation.trustee_id = nil
bsw@180 68 else
bsw@180 69 delegation.trustee_id = trustee_id
bsw@180 70 end
bsw/jbe@0 71
bsw/jbe@0 72 delegation:save()
bsw@278 73 --[[
bsw/jbe@0 74 if issue_id then
bsw/jbe@0 75 slot.put_into("notice", _"Your delegation for this issue has been updated.")
bsw/jbe@0 76 elseif area_id then
bsw/jbe@0 77 slot.put_into("notice", _"Your delegation for this area has been updated.")
bsw/jbe@0 78 else
bsw@248 79 slot.put_into("notice", _"Your delegation for this unit has been updated.")
bsw/jbe@0 80 end
bsw@278 81 --]]
bsw/jbe@0 82 end
bsw/jbe@0 83

Impressum / About Us