liquid_feedback_frontend

diff app/main/opinion/_action/update.lua @ 1649:4188405c2425

Rework of suggestion views
author bsw
date Thu Feb 11 15:48:02 2021 +0100 (2021-02-11)
parents 32cc544d5a5b
children
line diff
     1.1 --- a/app/main/opinion/_action/update.lua	Thu Feb 11 15:45:56 2021 +0100
     1.2 +++ b/app/main/opinion/_action/update.lua	Thu Feb 11 15:48:02 2021 +0100
     1.3 @@ -1,65 +1,6 @@
     1.4 -local member_id = app.session.member.id
     1.5 -
     1.6  local suggestion_id = param.get("suggestion_id", atom.integer)
     1.7 -
     1.8 -local opinion = Opinion:by_pk(member_id, suggestion_id)
     1.9 -
    1.10 -local suggestion = Suggestion:by_id(suggestion_id)
    1.11 -
    1.12  local degree = param.get("degree", atom.number)
    1.13  local fulfilled = param.get("fulfilled", atom.boolean)
    1.14  
    1.15 -
    1.16 -if not suggestion then
    1.17 -  slot.put_into("error", _"This suggestion has been meanwhile deleted")
    1.18 -  return false
    1.19 -end
    1.20 -
    1.21 --- TODO important m1 selectors returning result _SET_!
    1.22 -local issue = suggestion.initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
    1.23 -
    1.24 -if issue.closed then
    1.25 -  slot.put_into("error", _"This issue is already closed.")
    1.26 -  return false
    1.27 -elseif issue.fully_frozen then 
    1.28 -  slot.put_into("error", _"Voting for this issue has already begun.")
    1.29 -  return false
    1.30 -elseif 
    1.31 -  (issue.half_frozen and issue.phase_finished) or
    1.32 -  (not issue.accepted and issue.phase_finished) 
    1.33 -then
    1.34 -  slot.put_into("error", _"Current phase is already closed.")
    1.35 -  return false
    1.36 -end
    1.37 +return Opinion:update(suggestion_id, app.session.member_id, degree, fulfilled)
    1.38  
    1.39 -if degree == 0 then
    1.40 -  if opinion then
    1.41 -    opinion:destroy()
    1.42 -  end
    1.43 -  --slot.put_into("notice", _"Your rating has been deleted")
    1.44 -  return
    1.45 -end
    1.46 -
    1.47 -if degree ~= 0 and not app.session.member:has_voting_right_for_unit_id(suggestion.initiative.issue.area.unit_id) then
    1.48 -  return execute.view { module = "index", view = "403" }
    1.49 -end
    1.50 -
    1.51 -if not opinion then
    1.52 -  opinion = Opinion:new()
    1.53 -  opinion.member_id     = member_id
    1.54 -  opinion.suggestion_id = suggestion_id
    1.55 -  opinion.fulfilled     = false
    1.56 -end
    1.57 -
    1.58 -
    1.59 -if degree ~= nil then
    1.60 -  opinion.degree = degree
    1.61 -end
    1.62 -
    1.63 -if fulfilled ~= nil then
    1.64 -  opinion.fulfilled = fulfilled
    1.65 -end
    1.66 -
    1.67 -opinion:save()
    1.68 -
    1.69 ---slot.put_into("notice", _"Your rating has been updated")

Impressum / About Us