liquid_feedback_frontend
diff app/main/interest/_action/update.lua @ 1618:2f9e1e882de6
Add/remove interest via fetch
| author | bsw |
|---|---|
| date | Mon Feb 01 23:43:54 2021 +0100 (2021-02-01) |
| parents | 32cc544d5a5b |
| children |
line diff
1.1 --- a/app/main/interest/_action/update.lua Mon Feb 01 21:57:34 2021 +0100 1.2 +++ b/app/main/interest/_action/update.lua Mon Feb 01 23:43:54 2021 +0100 1.3 @@ -1,41 +1,5 @@ 1.4 -local issue_id = assert(param.get("issue_id", atom.integer), "no issue id given") 1.5 - 1.6 -local interest = Interest:by_pk(issue_id, app.session.member.id) 1.7 - 1.8 -local issue = Issue:new_selector():add_where{ "id = ?", issue_id }:for_share():single_object_mode():exec() 1.9 - 1.10 -if not app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then 1.11 - return execute.view { module = "index", view = "403" } 1.12 -end 1.13 +local issue_id = param.get("issue_id", atom.integer) 1.14 +local interested = param.get("interested", atom.boolean) 1.15 1.16 -if issue.closed then 1.17 - slot.put_into("error", _"This issue is already closed.") 1.18 - return false 1.19 -elseif issue.fully_frozen then 1.20 - slot.put_into("error", _"Voting for this issue has already begun.") 1.21 - return false 1.22 -elseif 1.23 - (issue.half_frozen and issue.phase_finished) or 1.24 - (not issue.accepted and issue.phase_finished) 1.25 -then 1.26 - slot.put_into("error", _"Current phase is already closed.") 1.27 - return false 1.28 -end 1.29 +return Interest:update(issue_id, app.session.member, interested) 1.30 1.31 -if param.get("delete", atom.boolean) then 1.32 - if interest then 1.33 - interest:destroy() 1.34 --- slot.put_into("notice", _"Interest removed") 1.35 - else 1.36 --- slot.put_into("notice", _"Interest already removed") 1.37 - end 1.38 - return 1.39 -end 1.40 - 1.41 -if not interest then 1.42 - interest = Interest:new() 1.43 - interest.issue_id = issue_id 1.44 - interest.member_id = app.session.member_id 1.45 - interest:save() 1.46 --- slot.put_into("notice", _"Interest updated") 1.47 -end