cerca

lean forum software (pmc local branch)
Log | Files | Refs | README | LICENSE

commit 1f4d8ff974ed2314293e5bdc051bfa9f17031c0e
parent 8a787befe40c3100249bb9b15b7b9c321c49b6a4
Author: cblgh <cblgh@cblgh.org>
Date:   Fri,  9 Aug 2024 15:10:09 +0200

admin: fix bug with confirmation during 1 week wait time

there were two different bugs that together made it impossible for
admins to confirm proposals made by other people before the waiting time
for allowing confirmations on self-made proposals had elapsed.

the one bug was that the confirm button was disabled in the interface.
the other was a database bug that was always entering the clause to exit
early for self proposals, regardless of whether the confirming admin was
the proposer or not

Diffstat:
Mdatabase/moderation.go | 3++-
Mhtml/admin.html | 4+++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/database/moderation.go b/database/moderation.go @@ -329,10 +329,11 @@ func (d DB) FinalizeProposedAction(proposalid, adminid int, decision bool) (fina return } + isSelfConfirm := proposerid == adminid timeSelfConfirmOK := proposalDate.Add(constants.PROPOSAL_SELF_CONFIRMATION_WAIT) // TODO (2024-01-07): render err message in admin view? // self confirms are not allowed at this point in time, exit early without performing any changes - if decision == constants.PROPOSAL_CONFIRM && !time.Now().After(timeSelfConfirmOK) { + if isSelfConfirm && (decision == constants.PROPOSAL_CONFIRM && !time.Now().After(timeSelfConfirmOK)) { err = tx.Commit() ed.Check(err, "commit transaction") finalErr = nil diff --git a/html/admin.html b/html/admin.html @@ -17,6 +17,7 @@ {{ "AdminViewPastActions" | translate }} <a href="/moderations">{{ "ModerationLog" | translate }}</a>. </p> </section> + {{ if .LoggedIn }} {{ $userID := .LoggedInID }} <section> @@ -62,7 +63,8 @@ <td> {{ $proposal.Action | tohtml }} </td> <td> {{ $proposal.Time | formatDateTime }} </td> <td><button type="submit" form="veto-{{$proposal.ID}}">{{ "AdminVeto" | translate }}</button></td> - <td><button {{ if not $proposal.TimePassed }} disabled title='{{ "AdminSelfConfirmationHover" | translate}}' {{ end }} type="submit" form="confirm-{{$proposal.ID}}">{{"AdminConfirm" | translate}}</button></td> + {{ $selfProposal := eq $userID $proposal.ProposerID }} + <td><button {{ if and $selfProposal (not $proposal.TimePassed) }} disabled title='{{ "AdminSelfConfirmationsHover" | translate}}' {{ end }} type="submit" form="confirm-{{$proposal.ID}}">{{"AdminConfirm" | translate}}</button></td> </tr> {{ end }} </table>