(c *context.Context, f form.InitializeLabels)
| 1007 | } |
| 1008 | |
| 1009 | func InitializeLabels(c *context.Context, f form.InitializeLabels) { |
| 1010 | if c.HasError() { |
| 1011 | c.RawRedirect(c.Repo.MakeURL("labels")) |
| 1012 | return |
| 1013 | } |
| 1014 | list, err := database.GetLabelTemplateFile(f.TemplateName) |
| 1015 | if err != nil { |
| 1016 | c.Flash.Error(c.Tr("repo.issues.label_templates.fail_to_load_file", f.TemplateName, err)) |
| 1017 | c.RawRedirect(c.Repo.MakeURL("labels")) |
| 1018 | return |
| 1019 | } |
| 1020 | |
| 1021 | labels := make([]*database.Label, len(list)) |
| 1022 | for i := 0; i < len(list); i++ { |
| 1023 | labels[i] = &database.Label{ |
| 1024 | RepoID: c.Repo.Repository.ID, |
| 1025 | Name: list[i][0], |
| 1026 | Color: list[i][1], |
| 1027 | } |
| 1028 | } |
| 1029 | if err := database.NewLabels(labels...); err != nil { |
| 1030 | c.Error(err, "new labels") |
| 1031 | return |
| 1032 | } |
| 1033 | c.RawRedirect(c.Repo.MakeURL("labels")) |
| 1034 | } |
| 1035 | |
| 1036 | func NewLabel(c *context.Context, f form.CreateLabel) { |
| 1037 | c.Data["Title"] = c.Tr("repo.labels") |
nothing calls this directly
no test coverage detected