|
7 | 7 | "errors" |
8 | 8 | "fmt" |
9 | 9 | "net/http" |
10 | | - "strconv" |
11 | 10 | "strings" |
12 | 11 |
|
13 | 12 | "code.gitea.io/gitea/models/db" |
@@ -390,96 +389,6 @@ func ViewProject(ctx *context.Context) { |
390 | 389 | ctx.HTML(http.StatusOK, tplProjectsView) |
391 | 390 | } |
392 | 391 |
|
393 | | -func getActionIssues(ctx *context.Context) issues_model.IssueList { |
394 | | - commaSeparatedIssueIDs := ctx.FormString("issue_ids") |
395 | | - if len(commaSeparatedIssueIDs) == 0 { |
396 | | - return nil |
397 | | - } |
398 | | - issueIDs := make([]int64, 0, 10) |
399 | | - for _, stringIssueID := range strings.Split(commaSeparatedIssueIDs, ",") { |
400 | | - issueID, err := strconv.ParseInt(stringIssueID, 10, 64) |
401 | | - if err != nil { |
402 | | - ctx.ServerError("ParseInt", err) |
403 | | - return nil |
404 | | - } |
405 | | - issueIDs = append(issueIDs, issueID) |
406 | | - } |
407 | | - issues, err := issues_model.GetIssuesByIDs(ctx, issueIDs) |
408 | | - if err != nil { |
409 | | - ctx.ServerError("GetIssuesByIDs", err) |
410 | | - return nil |
411 | | - } |
412 | | - // Check access rights for all issues |
413 | | - issueUnitEnabled := ctx.Repo.CanRead(unit.TypeIssues) |
414 | | - prUnitEnabled := ctx.Repo.CanRead(unit.TypePullRequests) |
415 | | - for _, issue := range issues { |
416 | | - if issue.RepoID != ctx.Repo.Repository.ID { |
417 | | - ctx.NotFound("some issue's RepoID is incorrect", errors.New("some issue's RepoID is incorrect")) |
418 | | - return nil |
419 | | - } |
420 | | - if issue.IsPull && !prUnitEnabled || !issue.IsPull && !issueUnitEnabled { |
421 | | - ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil) |
422 | | - return nil |
423 | | - } |
424 | | - if err = issue.LoadAttributes(ctx); err != nil { |
425 | | - ctx.ServerError("LoadAttributes", err) |
426 | | - return nil |
427 | | - } |
428 | | - } |
429 | | - return issues |
430 | | -} |
431 | | - |
432 | | -// UpdateIssueProject change an issue's project |
433 | | -func UpdateIssueProject(ctx *context.Context) { |
434 | | - issues := getActionIssues(ctx) |
435 | | - if ctx.Written() { |
436 | | - return |
437 | | - } |
438 | | - |
439 | | - if err := issues.LoadProjects(ctx); err != nil { |
440 | | - ctx.ServerError("LoadProjects", err) |
441 | | - return |
442 | | - } |
443 | | - |
444 | | - projectID := ctx.FormInt64("id") |
445 | | - var dstColumnID int64 |
446 | | - if projectID > 0 { |
447 | | - dstProject, err := project_model.GetProjectByID(ctx, projectID) |
448 | | - if err != nil { |
449 | | - ctx.ServerError("GetProjectByID", err) |
450 | | - return |
451 | | - } |
452 | | - if dstProject.OwnerID != ctx.ContextUser.ID { |
453 | | - ctx.JSON(http.StatusUnprocessableEntity, map[string]string{ |
454 | | - "message": fmt.Sprintf("Project[%d] is not in Owner[%d] as expected", dstProject.ID, ctx.ContextUser.ID), |
455 | | - }) |
456 | | - return |
457 | | - } |
458 | | - |
459 | | - dstDefaultColumn, err := dstProject.GetDefaultBoard(ctx) |
460 | | - if err != nil { |
461 | | - ctx.ServerError("GetDefaultBoard", err) |
462 | | - return |
463 | | - } |
464 | | - dstColumnID = dstDefaultColumn.ID |
465 | | - } |
466 | | - |
467 | | - for _, issue := range issues { |
468 | | - if issue.Project != nil { |
469 | | - if issue.Project.ID == projectID { |
470 | | - continue |
471 | | - } |
472 | | - } |
473 | | - |
474 | | - if err := issues_model.IssueAssignOrRemoveProject(ctx, issue, ctx.Doer, projectID, dstColumnID); err != nil { |
475 | | - ctx.ServerError("ChangeProjectAssign", err) |
476 | | - return |
477 | | - } |
478 | | - } |
479 | | - |
480 | | - ctx.JSONOK() |
481 | | -} |
482 | | - |
483 | 392 | // DeleteProjectBoard allows for the deletion of a project board |
484 | 393 | func DeleteProjectBoard(ctx *context.Context) { |
485 | 394 | if ctx.Doer == nil { |
|
0 commit comments