liquid_feedback_frontend

annotate app/main/opinion/_action/update.lua @ 1011:a0b6357f4421

Removed wrong preloading in admin cancel issue
author bsw
date Sun Aug 11 22:06:11 2013 +0200 (2013-08-11)
parents 1997cf1da04b
children 701a5cf6b067
rev   line source
bsw/jbe@0 1 local member_id = app.session.member.id
bsw/jbe@0 2
bsw/jbe@0 3 local suggestion_id = param.get("suggestion_id", atom.integer)
bsw/jbe@0 4
bsw/jbe@0 5 local opinion = Opinion:by_pk(member_id, suggestion_id)
bsw/jbe@0 6
bsw/jbe@6 7 local suggestion = Suggestion:by_id(suggestion_id)
bsw/jbe@6 8
bsw/jbe@6 9 if not suggestion then
bsw/jbe@6 10 slot.put_into("error", _"This suggestion has been meanwhile deleted")
bsw/jbe@6 11 return false
bsw/jbe@6 12 end
bsw/jbe@6 13
bsw/jbe@5 14 -- TODO important m1 selectors returning result _SET_!
bsw/jbe@6 15 local issue = suggestion.initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
bsw/jbe@5 16
bsw/jbe@5 17 if issue.closed then
bsw/jbe@5 18 slot.put_into("error", _"This issue is already closed.")
bsw/jbe@5 19 return false
bsw/jbe@5 20 elseif issue.fully_frozen then
bsw/jbe@5 21 slot.put_into("error", _"Voting for this issue has already begun.")
bsw/jbe@5 22 return false
bsw@964 23 elseif
bsw@964 24 (issue.half_frozen and issue.phase_finished) or
bsw@964 25 (not issue.accepted and issue.phase_finished)
bsw@964 26 then
bsw@964 27 slot.put_into("error", _"Current phase is already closed.")
bsw@964 28 return false
bsw/jbe@5 29 end
bsw/jbe@5 30
bsw@3 31 if param.get("delete") then
bsw@3 32 if opinion then
bsw@3 33 opinion:destroy()
bsw@3 34 end
bsw@280 35 --slot.put_into("notice", _"Your rating has been deleted")
bsw/jbe@0 36 return
bsw/jbe@0 37 end
bsw/jbe@0 38
bsw@281 39 local degree = param.get("degree", atom.number)
bsw@281 40 local fulfilled = param.get("fulfilled", atom.boolean)
bsw@281 41
bsw@281 42 if degree ~= 0 and not app.session.member:has_voting_right_for_unit_id(suggestion.initiative.issue.area.unit_id) then
bsw@281 43 error("access denied")
bsw@281 44 end
bsw@281 45
bsw/jbe@0 46 if not opinion then
bsw/jbe@0 47 opinion = Opinion:new()
bsw/jbe@0 48 opinion.member_id = member_id
bsw/jbe@0 49 opinion.suggestion_id = suggestion_id
bsw/jbe@0 50 opinion.fulfilled = false
bsw/jbe@0 51 end
bsw/jbe@0 52
bsw/jbe@0 53
bsw/jbe@0 54 if degree ~= nil then
bsw/jbe@0 55 opinion.degree = degree
bsw/jbe@0 56 end
bsw/jbe@0 57
bsw/jbe@0 58 if fulfilled ~= nil then
bsw/jbe@0 59 opinion.fulfilled = fulfilled
bsw/jbe@0 60 end
bsw/jbe@0 61
bsw/jbe@0 62 opinion:save()
bsw/jbe@0 63
bsw@280 64 --slot.put_into("notice", _"Your rating has been updated")

Impressum / About Us