forked from forgejo/forgejo
More db.DefaultContext
refactor (#27265)
Part of #27065 This PR touches functions used in templates. As templates are not static typed, errors are harder to find, but I hope I catch it all. I think some tests from other persons do not hurt.
This commit is contained in:
parent
3945c26722
commit
cf0df023be
66 changed files with 455 additions and 456 deletions
|
@ -1608,7 +1608,7 @@ func ViewIssue(ctx *context.Context) {
|
|||
marked[comment.PosterID] = comment.ShowRole
|
||||
participants = addParticipant(comment.Poster, participants)
|
||||
} else if comment.Type == issues_model.CommentTypeLabel {
|
||||
if err = comment.LoadLabel(); err != nil {
|
||||
if err = comment.LoadLabel(ctx); err != nil {
|
||||
ctx.ServerError("LoadLabel", err)
|
||||
return
|
||||
}
|
||||
|
@ -1629,7 +1629,7 @@ func ViewIssue(ctx *context.Context) {
|
|||
}
|
||||
} else if comment.Type == issues_model.CommentTypeProject {
|
||||
|
||||
if err = comment.LoadProject(); err != nil {
|
||||
if err = comment.LoadProject(ctx); err != nil {
|
||||
ctx.ServerError("LoadProject", err)
|
||||
return
|
||||
}
|
||||
|
@ -1648,12 +1648,12 @@ func ViewIssue(ctx *context.Context) {
|
|||
}
|
||||
|
||||
} else if comment.Type == issues_model.CommentTypeAssignees || comment.Type == issues_model.CommentTypeReviewRequest {
|
||||
if err = comment.LoadAssigneeUserAndTeam(); err != nil {
|
||||
if err = comment.LoadAssigneeUserAndTeam(ctx); err != nil {
|
||||
ctx.ServerError("LoadAssigneeUserAndTeam", err)
|
||||
return
|
||||
}
|
||||
} else if comment.Type == issues_model.CommentTypeRemoveDependency || comment.Type == issues_model.CommentTypeAddDependency {
|
||||
if err = comment.LoadDepIssueDetails(); err != nil {
|
||||
if err = comment.LoadDepIssueDetails(ctx); err != nil {
|
||||
if !issues_model.IsErrIssueNotExist(err) {
|
||||
ctx.ServerError("LoadDepIssueDetails", err)
|
||||
return
|
||||
|
@ -1670,7 +1670,7 @@ func ViewIssue(ctx *context.Context) {
|
|||
ctx.ServerError("RenderString", err)
|
||||
return
|
||||
}
|
||||
if err = comment.LoadReview(); err != nil && !issues_model.IsErrReviewNotExist(err) {
|
||||
if err = comment.LoadReview(ctx); err != nil && !issues_model.IsErrReviewNotExist(err) {
|
||||
ctx.ServerError("LoadReview", err)
|
||||
return
|
||||
}
|
||||
|
@ -1709,7 +1709,7 @@ func ViewIssue(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if err = comment.LoadResolveDoer(); err != nil {
|
||||
if err = comment.LoadResolveDoer(ctx); err != nil {
|
||||
ctx.ServerError("LoadResolveDoer", err)
|
||||
return
|
||||
}
|
||||
|
@ -1794,7 +1794,7 @@ func ViewIssue(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if ctx.Data["CanMarkConversation"], err = issues_model.CanMarkConversation(issue, ctx.Doer); err != nil {
|
||||
if ctx.Data["CanMarkConversation"], err = issues_model.CanMarkConversation(ctx, issue, ctx.Doer); err != nil {
|
||||
ctx.ServerError("CanMarkConversation", err)
|
||||
return
|
||||
}
|
||||
|
@ -2261,7 +2261,7 @@ func UpdateIssueDeadline(ctx *context.Context) {
|
|||
deadlineUnix = timeutil.TimeStamp(deadline.Unix())
|
||||
}
|
||||
|
||||
if err := issues_model.UpdateIssueDeadline(issue, deadlineUnix, ctx.Doer); err != nil {
|
||||
if err := issues_model.UpdateIssueDeadline(ctx, issue, deadlineUnix, ctx.Doer); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "UpdateIssueDeadline", err.Error())
|
||||
return
|
||||
}
|
||||
|
@ -3319,7 +3319,7 @@ func ChangeCommentReaction(ctx *context.Context) {
|
|||
}
|
||||
// Reload new reactions
|
||||
comment.Reactions = nil
|
||||
if err = comment.LoadReactions(ctx.Repo.Repository); err != nil {
|
||||
if err = comment.LoadReactions(ctx, ctx.Repo.Repository); err != nil {
|
||||
log.Info("comment.LoadReactions: %s", err)
|
||||
break
|
||||
}
|
||||
|
@ -3333,7 +3333,7 @@ func ChangeCommentReaction(ctx *context.Context) {
|
|||
|
||||
// Reload new reactions
|
||||
comment.Reactions = nil
|
||||
if err = comment.LoadReactions(ctx.Repo.Repository); err != nil {
|
||||
if err = comment.LoadReactions(ctx, ctx.Repo.Repository); err != nil {
|
||||
log.Info("comment.LoadReactions: %s", err)
|
||||
break
|
||||
}
|
||||
|
@ -3459,9 +3459,9 @@ func updateAttachments(ctx *context.Context, item any, files []string) error {
|
|||
if len(files) > 0 {
|
||||
switch content := item.(type) {
|
||||
case *issues_model.Issue:
|
||||
err = issues_model.UpdateIssueAttachments(content.ID, files)
|
||||
err = issues_model.UpdateIssueAttachments(ctx, content.ID, files)
|
||||
case *issues_model.Comment:
|
||||
err = content.UpdateAttachments(files)
|
||||
err = content.UpdateAttachments(ctx, files)
|
||||
default:
|
||||
return fmt.Errorf("unknown Type: %T", content)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue