bsw@886: local issue = Issue:new_selector():add_where{ "id = ?", param.get("issue_id", atom.integer) }:for_share():single_object_mode():exec() bsw@886: bsw@964: if issue.state ~= "voting" and not issue.closed then bsw@964: slot.put_into("error", _"Voting has not started yet.") bsw@890: return false bsw@890: end bsw@890: bsw@964: if issue.phase_finished or issue.closed then bsw@964: slot.put_into("error", _"This issue is already closed.") bsw@890: return false bsw@890: end bsw@890: bsw@886: local direct_voter = DirectVoter:by_pk(issue.id, app.session.member_id) bsw@886: bsw@886: if direct_voter then bsw@886: slot.select("error", function() bsw@886: ui.tag{ content = _"You already voted this issue" } bsw@886: end ) bsw@886: return false bsw@886: end bsw@886: bsw@886: local non_voter = NonVoter:by_pk(issue.id, app.session.member_id) bsw@886: bsw@886: if non_voter and param.get("delete", atom.boolean) then bsw@886: non_voter:destroy() bsw@886: elseif not non_voter then bsw@886: non_voter = NonVoter:new() bsw@886: non_voter.issue_id = issue.id bsw@886: non_voter.member_id = app.session.member_id bsw@886: non_voter:save() bsw@886: end