liquid_feedback_frontend
annotate app/main/vote/_action/non_voter.lua @ 1859:02c34183b6df
Fixed wrong filename in INSTALL file
author | bsw |
---|---|
date | Tue Nov 28 18:54:51 2023 +0100 (17 months ago) |
parents | 1997cf1da04b |
children |
rev | line source |
---|---|
bsw@886 | 1 local issue = Issue:new_selector():add_where{ "id = ?", param.get("issue_id", atom.integer) }:for_share():single_object_mode():exec() |
bsw@886 | 2 |
bsw@964 | 3 if issue.state ~= "voting" and not issue.closed then |
bsw@964 | 4 slot.put_into("error", _"Voting has not started yet.") |
bsw@890 | 5 return false |
bsw@890 | 6 end |
bsw@890 | 7 |
bsw@964 | 8 if issue.phase_finished or issue.closed then |
bsw@964 | 9 slot.put_into("error", _"This issue is already closed.") |
bsw@890 | 10 return false |
bsw@890 | 11 end |
bsw@890 | 12 |
bsw@886 | 13 local direct_voter = DirectVoter:by_pk(issue.id, app.session.member_id) |
bsw@886 | 14 |
bsw@886 | 15 if direct_voter then |
bsw@886 | 16 slot.select("error", function() |
bsw@886 | 17 ui.tag{ content = _"You already voted this issue" } |
bsw@886 | 18 end ) |
bsw@886 | 19 return false |
bsw@886 | 20 end |
bsw@886 | 21 |
bsw@886 | 22 local non_voter = NonVoter:by_pk(issue.id, app.session.member_id) |
bsw@886 | 23 |
bsw@886 | 24 if non_voter and param.get("delete", atom.boolean) then |
bsw@886 | 25 non_voter:destroy() |
bsw@886 | 26 elseif not non_voter then |
bsw@886 | 27 non_voter = NonVoter:new() |
bsw@886 | 28 non_voter.issue_id = issue.id |
bsw@886 | 29 non_voter.member_id = app.session.member_id |
bsw@886 | 30 non_voter:save() |
bsw@886 | 31 end |