@@ -410,21 +410,19 @@ func AddBoardToProjectPost(ctx *context.Context, form auth.EditProjectBoardTitle
410
410
})
411
411
}
412
412
413
- // EditProjectBoardTitle allows a project board's title to be updated
414
- func EditProjectBoardTitle (ctx * context.Context , form auth.EditProjectBoardTitleForm ) {
415
-
413
+ func checkProjectBoardChangePermissions (ctx * context.Context ) (* models.Project , * models.ProjectBoard ) {
416
414
if ctx .User == nil {
417
415
ctx .JSON (403 , map [string ]string {
418
416
"message" : "Only signed in users are allowed to perform this action." ,
419
417
})
420
- return
418
+ return nil , nil
421
419
}
422
420
423
421
if ! ctx .Repo .IsOwner () && ! ctx .Repo .IsAdmin () && ! ctx .Repo .CanAccess (models .AccessModeWrite , models .UnitTypeProjects ) {
424
422
ctx .JSON (403 , map [string ]string {
425
423
"message" : "Only authorized users are allowed to perform this action." ,
426
424
})
427
- return
425
+ return nil , nil
428
426
}
429
427
430
428
project , err := models .GetProjectByID (ctx .ParamsInt64 (":id" ))
@@ -434,33 +432,43 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle
434
432
} else {
435
433
ctx .ServerError ("GetProjectByID" , err )
436
434
}
437
- return
435
+ return nil , nil
438
436
}
439
437
440
438
board , err := models .GetProjectBoard (ctx .ParamsInt64 (":boardID" ))
441
439
if err != nil {
442
440
ctx .InternalServerError (err )
443
- return
441
+ return nil , nil
444
442
}
445
443
if board .ProjectID != ctx .ParamsInt64 (":id" ) {
446
444
ctx .JSON (422 , map [string ]string {
447
445
"message" : fmt .Sprintf ("ProjectBoard[%d] is not in Project[%d] as expected" , board .ID , project .ID ),
448
446
})
449
- return
447
+ return nil , nil
450
448
}
451
449
452
450
if project .RepoID != ctx .Repo .Repository .ID {
453
451
ctx .JSON (422 , map [string ]string {
454
452
"message" : fmt .Sprintf ("ProjectBoard[%d] is not in Repository[%d] as expected" , board .ID , ctx .Repo .Repository .ID ),
455
453
})
454
+ return nil , nil
455
+ }
456
+ return project , board
457
+ }
458
+
459
+ // EditProjectBoardTitle allows a project board's title to be updated
460
+ func EditProjectBoardTitle (ctx * context.Context , form auth.EditProjectBoardTitleForm ) {
461
+
462
+ _ , board := checkProjectBoardChangePermissions (ctx )
463
+ if ctx .Written () {
456
464
return
457
465
}
458
466
459
467
if form .Title != "" {
460
468
board .Title = form .Title
461
469
}
462
470
463
- if err = models .UpdateProjectBoard (board ); err != nil {
471
+ if err : = models .UpdateProjectBoard (board ); err != nil {
464
472
ctx .ServerError ("UpdateProjectBoard" , err )
465
473
return
466
474
}
@@ -470,6 +478,24 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle
470
478
})
471
479
}
472
480
481
+ // SetDefaultProjectBoard set default board for uncategorized issues/pulls
482
+ func SetDefaultProjectBoard (ctx * context.Context ) {
483
+
484
+ project , board := checkProjectBoardChangePermissions (ctx )
485
+ if ctx .Written () {
486
+ return
487
+ }
488
+
489
+ if err := models .SetDefaultBoard (project .ID , board .ID ); err != nil {
490
+ ctx .InternalServerError (err )
491
+ return
492
+ }
493
+
494
+ ctx .JSON (200 , map [string ]interface {}{
495
+ "ok" : true ,
496
+ })
497
+ }
498
+
473
499
// MoveIssueAcrossBoards move a card from one board to another in a project
474
500
func MoveIssueAcrossBoards (ctx * context.Context ) {
475
501
0 commit comments