liquid_feedback_frontend
view 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 |
line source
1 local issue_id = assert(param.get("issue_id", atom.integer), "no issue id given")
3 local interest = Interest:by_pk(issue_id, app.session.member.id)
5 local issue = Issue:new_selector():add_where{ "id = ?", issue_id }:for_share():single_object_mode():exec()
7 if not app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
8 return execute.view { module = "index", view = "403" }
9 end
11 if issue.closed then
12 slot.put_into("error", _"This issue is already closed.")
13 return false
14 elseif issue.fully_frozen then
15 slot.put_into("error", _"Voting for this issue has already begun.")
16 return false
17 elseif
18 (issue.half_frozen and issue.phase_finished) or
19 (not issue.accepted and issue.phase_finished)
20 then
21 slot.put_into("error", _"Current phase is already closed.")
22 return false
23 end
25 if param.get("delete", atom.boolean) then
26 if interest then
27 interest:destroy()
28 -- slot.put_into("notice", _"Interest removed")
29 else
30 -- slot.put_into("notice", _"Interest already removed")
31 end
32 return
33 end
35 if not interest then
36 interest = Interest:new()
37 interest.issue_id = issue_id
38 interest.member_id = app.session.member_id
39 interest:save()
40 -- slot.put_into("notice", _"Interest updated")
41 end