@@ -10,6 +10,7 @@ import (
1010 "strings"
1111
1212 "code.gitea.io/gitea/models"
13+ "code.gitea.io/gitea/modules/setting"
1314 "code.gitea.io/gitea/routers/utils"
1415
1516 "github.com/Unknwon/com"
@@ -308,6 +309,32 @@ func (f *ReactionForm) Validate(ctx *macaron.Context, errs binding.Errors) bindi
308309 return validate (errs , ctx .Data , f , ctx .Locale )
309310}
310311
312+ // IssueLockForm form for locking an issue
313+ type IssueLockForm struct {
314+ Reason string `binding:"Required"`
315+ }
316+
317+ // Validate validates the fields
318+ func (i * IssueLockForm ) Validate (ctx * macaron.Context , errs binding.Errors ) binding.Errors {
319+ return validate (errs , ctx .Data , i , ctx .Locale )
320+ }
321+
322+ // HasValidReason checks to make sure that the reason submitted in
323+ // the form matches any of the values in the config
324+ func (i IssueLockForm ) HasValidReason () bool {
325+ if strings .TrimSpace (i .Reason ) == "" {
326+ return true
327+ }
328+
329+ for _ , v := range setting .Repository .Issue .LockReasons {
330+ if v == i .Reason {
331+ return true
332+ }
333+ }
334+
335+ return false
336+ }
337+
311338// _____ .__.__ __
312339// / \ |__| | ____ _______/ |_ ____ ____ ____
313340// / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
0 commit comments