bsw/jbe@0: local issue_id = assert(param.get("issue_id", atom.integer), "no issue id given") bsw/jbe@5: bsw/jbe@0: local interest = Interest:by_pk(issue_id, app.session.member.id) bsw/jbe@0: bsw@92: local issue = Issue:new_selector():add_where{ "id = ?", issue_id }:for_share():single_object_mode():exec() bsw/jbe@5: bsw/jbe@5: if issue.closed then bsw/jbe@5: slot.put_into("error", _"This issue is already closed.") bsw/jbe@5: return false bsw/jbe@5: elseif issue.fully_frozen then bsw/jbe@5: slot.put_into("error", _"Voting for this issue has already begun.") bsw/jbe@5: return false bsw@964: elseif bsw@964: (issue.half_frozen and issue.phase_finished) or bsw@964: (not issue.accepted and issue.phase_finished) bsw@964: then bsw@964: slot.put_into("error", _"Current phase is already closed.") bsw@964: return false bsw@964: end bsw@964: bsw/jbe@5: end bsw/jbe@5: bsw/jbe@0: if param.get("delete", atom.boolean) then bsw/jbe@0: if interest then bsw/jbe@0: interest:destroy() bsw@277: --slot.put_into("notice", _"Interest removed") bsw/jbe@0: else bsw@277: --slot.put_into("notice", _"Interest not existent") bsw/jbe@0: end bsw/jbe@0: return bsw/jbe@0: end bsw/jbe@0: bsw@281: if not app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then bsw@281: error("access denied") bsw@281: end bsw@281: bsw/jbe@0: if not interest then bsw/jbe@0: interest = Interest:new() bsw/jbe@0: interest.issue_id = issue_id bsw/jbe@0: interest.member_id = app.session.member_id bsw/jbe@0: end bsw/jbe@0: bsw/jbe@0: interest:save() bsw/jbe@0: bsw@277: --slot.put_into("notice", _"Interest updated")