liquid_feedback_frontend

view app/main/opinion/_action/update.lua @ 964:1997cf1da04b

Added support for finished phases
author bsw
date Thu Feb 21 19:32:48 2013 +0100 (2013-02-21)
parents b77e6a17ca77
children 701a5cf6b067
line source
1 local member_id = app.session.member.id
3 local suggestion_id = param.get("suggestion_id", atom.integer)
5 local opinion = Opinion:by_pk(member_id, suggestion_id)
7 local suggestion = Suggestion:by_id(suggestion_id)
9 if not suggestion then
10 slot.put_into("error", _"This suggestion has been meanwhile deleted")
11 return false
12 end
14 -- TODO important m1 selectors returning result _SET_!
15 local issue = suggestion.initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
17 if issue.closed then
18 slot.put_into("error", _"This issue is already closed.")
19 return false
20 elseif issue.fully_frozen then
21 slot.put_into("error", _"Voting for this issue has already begun.")
22 return false
23 elseif
24 (issue.half_frozen and issue.phase_finished) or
25 (not issue.accepted and issue.phase_finished)
26 then
27 slot.put_into("error", _"Current phase is already closed.")
28 return false
29 end
31 if param.get("delete") then
32 if opinion then
33 opinion:destroy()
34 end
35 --slot.put_into("notice", _"Your rating has been deleted")
36 return
37 end
39 local degree = param.get("degree", atom.number)
40 local fulfilled = param.get("fulfilled", atom.boolean)
42 if degree ~= 0 and not app.session.member:has_voting_right_for_unit_id(suggestion.initiative.issue.area.unit_id) then
43 error("access denied")
44 end
46 if not opinion then
47 opinion = Opinion:new()
48 opinion.member_id = member_id
49 opinion.suggestion_id = suggestion_id
50 opinion.fulfilled = false
51 end
54 if degree ~= nil then
55 opinion.degree = degree
56 end
58 if fulfilled ~= nil then
59 opinion.fulfilled = fulfilled
60 end
62 opinion:save()
64 --slot.put_into("notice", _"Your rating has been updated")

Impressum / About Us