(c *context.Context, f form.NewIssue)
| 343 | } |
| 344 | |
| 345 | func ValidateRepoMetas(c *context.Context, f form.NewIssue) ([]int64, int64, int64) { |
| 346 | var ( |
| 347 | repo = c.Repo.Repository |
| 348 | err error |
| 349 | ) |
| 350 | |
| 351 | labels := RetrieveRepoMetas(c, c.Repo.Repository) |
| 352 | if c.Written() { |
| 353 | return nil, 0, 0 |
| 354 | } |
| 355 | |
| 356 | if !c.Repo.IsWriter() { |
| 357 | return nil, 0, 0 |
| 358 | } |
| 359 | |
| 360 | // Check labels. |
| 361 | labelIDs := tool.StringsToInt64s(strings.Split(f.LabelIDs, ",")) |
| 362 | labelIDMark := tool.Int64sToMap(labelIDs) |
| 363 | hasSelected := false |
| 364 | for i := range labels { |
| 365 | if labelIDMark[labels[i].ID] { |
| 366 | labels[i].IsChecked = true |
| 367 | hasSelected = true |
| 368 | } |
| 369 | } |
| 370 | c.Data["HasSelectedLabel"] = hasSelected |
| 371 | c.Data["label_ids"] = f.LabelIDs |
| 372 | c.Data["Labels"] = labels |
| 373 | |
| 374 | // Check milestone. |
| 375 | milestoneID := f.MilestoneID |
| 376 | if milestoneID > 0 { |
| 377 | c.Data["Milestone"], err = repo.GetMilestoneByID(milestoneID) |
| 378 | if err != nil { |
| 379 | c.Error(err, "get milestone by ID") |
| 380 | return nil, 0, 0 |
| 381 | } |
| 382 | c.Data["milestone_id"] = milestoneID |
| 383 | } |
| 384 | |
| 385 | // Check assignee. |
| 386 | assigneeID := f.AssigneeID |
| 387 | if assigneeID > 0 { |
| 388 | c.Data["Assignee"], err = repo.GetAssigneeByID(assigneeID) |
| 389 | if err != nil { |
| 390 | c.Error(err, "get assignee by ID") |
| 391 | return nil, 0, 0 |
| 392 | } |
| 393 | c.Data["assignee_id"] = assigneeID |
| 394 | } |
| 395 | |
| 396 | return labelIDs, milestoneID, assigneeID |
| 397 | } |
| 398 | |
| 399 | func NewIssuePost(c *context.Context, f form.NewIssue) { |
| 400 | c.Data["Title"] = c.Tr("repo.issues.new") |
no test coverage detected