mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 14:00:04 +02:00
Implement "conversation lock" for issue comments (#5073)
This commit is contained in:
parent
64ce159a6e
commit
44114b38e6
19 changed files with 435 additions and 4 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/routers/utils"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
|
@ -308,6 +309,32 @@ func (f *ReactionForm) Validate(ctx *macaron.Context, errs binding.Errors) bindi
|
|||
return validate(errs, ctx.Data, f, ctx.Locale)
|
||||
}
|
||||
|
||||
// IssueLockForm form for locking an issue
|
||||
type IssueLockForm struct {
|
||||
Reason string `binding:"Required"`
|
||||
}
|
||||
|
||||
// Validate validates the fields
|
||||
func (i *IssueLockForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||
return validate(errs, ctx.Data, i, ctx.Locale)
|
||||
}
|
||||
|
||||
// HasValidReason checks to make sure that the reason submitted in
|
||||
// the form matches any of the values in the config
|
||||
func (i IssueLockForm) HasValidReason() bool {
|
||||
if strings.TrimSpace(i.Reason) == "" {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, v := range setting.Repository.Issue.LockReasons {
|
||||
if v == i.Reason {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// _____ .__.__ __
|
||||
// / \ |__| | ____ _______/ |_ ____ ____ ____
|
||||
// / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue