liquid_feedback_frontend
view app/main/opinion/_action/update.lua @ 1559:7eda69e1d14f
Fixed layout of incoming delegations in vote view
| author | bsw | 
|---|---|
| date | Tue Nov 10 20:29:19 2020 +0100 (2020-11-10) | 
| parents | 32cc544d5a5b | 
| children | 4188405c2425 | 
 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 local degree = param.get("degree", atom.number)
    10 local fulfilled = param.get("fulfilled", atom.boolean)
    13 if not suggestion then
    14   slot.put_into("error", _"This suggestion has been meanwhile deleted")
    15   return false
    16 end
    18 -- TODO important m1 selectors returning result _SET_!
    19 local issue = suggestion.initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
    21 if issue.closed then
    22   slot.put_into("error", _"This issue is already closed.")
    23   return false
    24 elseif issue.fully_frozen then 
    25   slot.put_into("error", _"Voting for this issue has already begun.")
    26   return false
    27 elseif 
    28   (issue.half_frozen and issue.phase_finished) or
    29   (not issue.accepted and issue.phase_finished) 
    30 then
    31   slot.put_into("error", _"Current phase is already closed.")
    32   return false
    33 end
    35 if degree == 0 then
    36   if opinion then
    37     opinion:destroy()
    38   end
    39   --slot.put_into("notice", _"Your rating has been deleted")
    40   return
    41 end
    43 if degree ~= 0 and not app.session.member:has_voting_right_for_unit_id(suggestion.initiative.issue.area.unit_id) then
    44   return execute.view { module = "index", view = "403" }
    45 end
    47 if not opinion then
    48   opinion = Opinion:new()
    49   opinion.member_id     = member_id
    50   opinion.suggestion_id = suggestion_id
    51   opinion.fulfilled     = false
    52 end
    55 if degree ~= nil then
    56   opinion.degree = degree
    57 end
    59 if fulfilled ~= nil then
    60   opinion.fulfilled = fulfilled
    61 end
    63 opinion:save()
    65 --slot.put_into("notice", _"Your rating has been updated")
