Reimplemented usage of Comment Depenendent Issue (in struct) in comments
Signed-off-by: Konrad <konrad@kola-entertainments.de>
This commit is contained in:
parent
9609609627
commit
752406c40c
|
|
@ -97,6 +97,7 @@ type Comment struct {
|
||||||
OldTitle string
|
OldTitle string
|
||||||
NewTitle string
|
NewTitle string
|
||||||
DependentIssueID int64
|
DependentIssueID int64
|
||||||
|
DependentIssue *Issue `xorm:"-"`
|
||||||
|
|
||||||
CommitID int64
|
CommitID int64
|
||||||
Line int64
|
Line int64
|
||||||
|
|
@ -117,25 +118,30 @@ type Comment struct {
|
||||||
ShowTag CommentTag `xorm:"-"`
|
ShowTag CommentTag `xorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AfterLoad is invoked from XORM after setting the values of all fields of this object.
|
// AfterSet is invoked from XORM after setting the value of a field of this object.
|
||||||
func (c *Comment) AfterLoad(session *xorm.Session) {
|
func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
|
||||||
c.Created = time.Unix(c.CreatedUnix, 0).Local()
|
|
||||||
c.Updated = time.Unix(c.UpdatedUnix, 0).Local()
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
c.Attachments, err = getAttachmentsByCommentID(session, c.ID)
|
switch colName {
|
||||||
if err != nil {
|
case "id":
|
||||||
log.Error(3, "getAttachmentsByCommentID[%d]: %v", c.ID, err)
|
c.Attachments, err = GetAttachmentsByCommentID(c.ID)
|
||||||
}
|
if err != nil {
|
||||||
|
log.Error(3, "GetAttachmentsByCommentID[%d]: %v", c.ID, err)
|
||||||
c.Poster, err = getUserByID(session, c.PosterID)
|
|
||||||
if err != nil {
|
|
||||||
if IsErrUserNotExist(err) {
|
|
||||||
c.PosterID = -1
|
|
||||||
c.Poster = NewGhostUser()
|
|
||||||
} else {
|
|
||||||
log.Error(3, "getUserByID[%d]: %v", c.ID, err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "poster_id":
|
||||||
|
c.Poster, err = GetUserByID(c.PosterID)
|
||||||
|
if err != nil {
|
||||||
|
if IsErrUserNotExist(err) {
|
||||||
|
c.PosterID = -1
|
||||||
|
c.Poster = NewGhostUser()
|
||||||
|
} else {
|
||||||
|
log.Error(3, "GetUserByID[%d]: %v", c.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "created_unix":
|
||||||
|
c.Created = time.Unix(c.CreatedUnix, 0).Local()
|
||||||
|
case "updated_unix":
|
||||||
|
c.Updated = time.Unix(c.UpdatedUnix, 0).Local()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,6 +275,18 @@ func (c *Comment) LoadAssignees() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadDepIssueDetails loads Dependent Issue Details
|
||||||
|
func (c *Comment) LoadDepIssueDetails() error {
|
||||||
|
var err error
|
||||||
|
if c.DependentIssueID > 0 {
|
||||||
|
c.DependentIssue, err = getIssueByID(x, c.DependentIssueID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// MailParticipants sends new comment emails to repository watchers
|
// MailParticipants sends new comment emails to repository watchers
|
||||||
// and mentioned people.
|
// and mentioned people.
|
||||||
func (c *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (err error) {
|
func (c *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (err error) {
|
||||||
|
|
@ -319,6 +337,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
|
||||||
Content: opts.Content,
|
Content: opts.Content,
|
||||||
OldTitle: opts.OldTitle,
|
OldTitle: opts.OldTitle,
|
||||||
NewTitle: opts.NewTitle,
|
NewTitle: opts.NewTitle,
|
||||||
|
DependentIssue: opts.DependentIssue,
|
||||||
DependentIssueID: depID,
|
DependentIssueID: depID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -508,7 +527,6 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
|
||||||
Repo: issue.Repo,
|
Repo: issue.Repo,
|
||||||
Issue: issue,
|
Issue: issue,
|
||||||
DependentIssue: dependentIssue,
|
DependentIssue: dependentIssue,
|
||||||
Content: dependentIssue.Title,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/notification"
|
"code.gitea.io/gitea/modules/notification"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -683,6 +684,11 @@ func ViewIssue(ctx *context.Context) {
|
||||||
ctx.Handle(500, "LoadAssignees", err)
|
ctx.Handle(500, "LoadAssignees", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if comment.Type == models.CommentTypeRemoveDependency || comment.Type == models.CommentTypeAddDependency {
|
||||||
|
if err = comment.LoadDepIssueDetails(); err != nil {
|
||||||
|
ctx.Handle(http.StatusInternalServerError, "LoadDepIssueDetails", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,8 +192,8 @@
|
||||||
</span>
|
</span>
|
||||||
<div class="detail">
|
<div class="detail">
|
||||||
<span class="octicon octicon-plus"></span>
|
<span class="octicon octicon-plus"></span>
|
||||||
<span class="text grey">{{.Content}}</span>
|
<span class="text grey"><a href="{{$.RepoLink}}/issues/{{.DependentIssue.Index}}">#{{.DependentIssue.Index}} {{.DependentIssue.Title}}</a></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{else if eq .Type 17}}
|
{{else if eq .Type 17}}
|
||||||
<div class="event">
|
<div class="event">
|
||||||
|
|
@ -206,7 +206,7 @@
|
||||||
</span>
|
</span>
|
||||||
<div class="detail">
|
<div class="detail">
|
||||||
<span class="text grey octicon octicon-trashcan"></span>
|
<span class="text grey octicon octicon-trashcan"></span>
|
||||||
<span class="text grey">{{.Content}} </span>
|
<span class="text grey"><a href="{{$.RepoLink}}/issues/{{.DependentIssue.Index}}">#{{.DependentIssue.Index}} {{.DependentIssue.Title}}</a></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user