|
|
@ -180,6 +180,7 @@ func NewIssue(ctx *middleware.Context) { |
|
|
|
ctx.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled |
|
|
|
ctx.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled |
|
|
|
ctx.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes |
|
|
|
ctx.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ctx.User.IsAdmin { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
repo = ctx.Repo.Repository |
|
|
|
repo = ctx.Repo.Repository |
|
|
|
err error |
|
|
|
err error |
|
|
@ -189,6 +190,7 @@ func NewIssue(ctx *middleware.Context) { |
|
|
|
ctx.Handle(500, "GetLabelsByRepoID: %v", err) |
|
|
|
ctx.Handle(500, "GetLabelsByRepoID: %v", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// // Get all milestones.
|
|
|
|
// // Get all milestones.
|
|
|
|
// ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
|
|
|
|
// ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
|
|
|
@ -219,6 +221,31 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) { |
|
|
|
ctx.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled |
|
|
|
ctx.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled |
|
|
|
ctx.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes |
|
|
|
ctx.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
|
|
|
repo = ctx.Repo.Repository |
|
|
|
|
|
|
|
labelIDs []int64 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
if ctx.User.IsAdmin { |
|
|
|
|
|
|
|
// Check labels.
|
|
|
|
|
|
|
|
labelIDs = base.StringsToInt64s(strings.Split(form.LabelIDs, ",")) |
|
|
|
|
|
|
|
labelIDMark := base.Int64sToMap(labelIDs) |
|
|
|
|
|
|
|
labels, err := models.GetLabelsByRepoID(repo.ID) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Handle(500, "GetLabelsByRepoID: %v", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
hasSelected := false |
|
|
|
|
|
|
|
for i := range labels { |
|
|
|
|
|
|
|
if labelIDMark[labels[i].ID] { |
|
|
|
|
|
|
|
labels[i].IsChecked = true |
|
|
|
|
|
|
|
hasSelected = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["HasSelectedLabel"] = hasSelected |
|
|
|
|
|
|
|
ctx.Data["label_ids"] = form.LabelIDs |
|
|
|
|
|
|
|
ctx.Data["Labels"] = labels |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ctx.HasError() { |
|
|
|
if ctx.HasError() { |
|
|
|
ctx.HTML(200, ISSUE_NEW) |
|
|
|
ctx.HTML(200, ISSUE_NEW) |
|
|
|
return |
|
|
|
return |
|
|
@ -226,18 +253,17 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) { |
|
|
|
|
|
|
|
|
|
|
|
issue := &models.Issue{ |
|
|
|
issue := &models.Issue{ |
|
|
|
RepoID: ctx.Repo.Repository.ID, |
|
|
|
RepoID: ctx.Repo.Repository.ID, |
|
|
|
Index: int64(ctx.Repo.Repository.NumIssues) + 1, |
|
|
|
Index: int64(repo.NumIssues) + 1, |
|
|
|
Name: form.Title, |
|
|
|
Name: form.Title, |
|
|
|
PosterID: ctx.User.Id, |
|
|
|
PosterID: ctx.User.Id, |
|
|
|
// MilestoneID: form.MilestoneID,
|
|
|
|
// MilestoneID: form.MilestoneID,
|
|
|
|
// AssigneeID: form.AssigneeID,
|
|
|
|
// AssigneeID: form.AssigneeID,
|
|
|
|
// LabelIDs: "$" + strings.Join(form.LabelIDs, "|$") + "|",
|
|
|
|
|
|
|
|
Content: form.Content, |
|
|
|
Content: form.Content, |
|
|
|
} |
|
|
|
} |
|
|
|
if err := models.NewIssue(issue); err != nil { |
|
|
|
if err := models.NewIssue(issue, labelIDs); err != nil { |
|
|
|
ctx.Handle(500, "NewIssue", err) |
|
|
|
ctx.Handle(500, "NewIssue", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} else if err := models.NewIssueUserPairs(ctx.Repo.Repository, issue); err != nil { |
|
|
|
} else if err := models.NewIssueUserPairs(repo, issue); err != nil { |
|
|
|
ctx.Handle(500, "NewIssue", err) |
|
|
|
ctx.Handle(500, "NewIssue", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|