liquid_feedback_frontend

annotate app/main/interest/_action/update.lua @ 1309:32cc544d5a5b

Cumulative patch for upcoming frontend version 4
author bsw/jbe
date Sun Jul 15 14:07:29 2018 +0200 (2018-07-15)
parents 701a5cf6b067
children 2f9e1e882de6
rev   line source
bsw/jbe@0 1 local issue_id = assert(param.get("issue_id", atom.integer), "no issue id given")
bsw/jbe@5 2
bsw/jbe@0 3 local interest = Interest:by_pk(issue_id, app.session.member.id)
bsw/jbe@0 4
bsw@92 5 local issue = Issue:new_selector():add_where{ "id = ?", issue_id }:for_share():single_object_mode():exec()
bsw/jbe@5 6
bsw@1045 7 if not app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
bsw/jbe@1309 8 return execute.view { module = "index", view = "403" }
bsw@1045 9 end
bsw@1045 10
bsw/jbe@5 11 if issue.closed then
bsw/jbe@5 12 slot.put_into("error", _"This issue is already closed.")
bsw/jbe@5 13 return false
bsw/jbe@5 14 elseif issue.fully_frozen then
bsw/jbe@5 15 slot.put_into("error", _"Voting for this issue has already begun.")
bsw/jbe@5 16 return false
bsw@964 17 elseif
bsw@964 18 (issue.half_frozen and issue.phase_finished) or
bsw@964 19 (not issue.accepted and issue.phase_finished)
bsw@964 20 then
bsw@964 21 slot.put_into("error", _"Current phase is already closed.")
bsw@964 22 return false
bsw@964 23 end
bsw@964 24
bsw/jbe@0 25 if param.get("delete", atom.boolean) then
bsw/jbe@0 26 if interest then
bsw/jbe@0 27 interest:destroy()
bsw/jbe@1309 28 -- slot.put_into("notice", _"Interest removed")
bsw/jbe@0 29 else
bsw/jbe@1309 30 -- slot.put_into("notice", _"Interest already removed")
bsw/jbe@0 31 end
bsw/jbe@0 32 return
bsw/jbe@0 33 end
bsw/jbe@0 34
bsw/jbe@0 35 if not interest then
bsw/jbe@0 36 interest = Interest:new()
bsw/jbe@0 37 interest.issue_id = issue_id
bsw/jbe@0 38 interest.member_id = app.session.member_id
bsw@1045 39 interest:save()
bsw/jbe@1309 40 -- slot.put_into("notice", _"Interest updated")
bsw/jbe@0 41 end

Impressum / About Us