forked from forgejo/forgejo
Move issues related files into models/issues (#19931)
* Move access and repo permission to models/perm/access * fix test * fix git test * Move functions sequence * Some improvements per @KN4CK3R and @delvh * Move issues related code to models/issues * Move some issues related sub package * Merge * Fix test * Fix test * Fix test * Fix test * Rename some files
This commit is contained in:
parent
3708ca8e28
commit
1a9821f57a
180 changed files with 3667 additions and 3677 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
|
@ -43,13 +43,13 @@ func ListLabels(ctx *context.APIContext) {
|
|||
// "200":
|
||||
// "$ref": "#/responses/LabelList"
|
||||
|
||||
labels, err := models.GetLabelsByOrgID(ctx, ctx.Org.Organization.ID, ctx.FormString("sort"), utils.GetListOptions(ctx))
|
||||
labels, err := issues_model.GetLabelsByOrgID(ctx, ctx.Org.Organization.ID, ctx.FormString("sort"), utils.GetListOptions(ctx))
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetLabelsByOrgID", err)
|
||||
return
|
||||
}
|
||||
|
||||
count, err := models.CountLabelsByOrgID(ctx.Org.Organization.ID)
|
||||
count, err := issues_model.CountLabelsByOrgID(ctx.Org.Organization.ID)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
|
@ -88,18 +88,18 @@ func CreateLabel(ctx *context.APIContext) {
|
|||
if len(form.Color) == 6 {
|
||||
form.Color = "#" + form.Color
|
||||
}
|
||||
if !models.LabelColorPattern.MatchString(form.Color) {
|
||||
if !issues_model.LabelColorPattern.MatchString(form.Color) {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "ColorPattern", fmt.Errorf("bad color code: %s", form.Color))
|
||||
return
|
||||
}
|
||||
|
||||
label := &models.Label{
|
||||
label := &issues_model.Label{
|
||||
Name: form.Name,
|
||||
Color: form.Color,
|
||||
OrgID: ctx.Org.Organization.ID,
|
||||
Description: form.Description,
|
||||
}
|
||||
if err := models.NewLabel(ctx, label); err != nil {
|
||||
if err := issues_model.NewLabel(ctx, label); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "NewLabel", err)
|
||||
return
|
||||
}
|
||||
|
@ -131,17 +131,17 @@ func GetLabel(ctx *context.APIContext) {
|
|||
// "$ref": "#/responses/Label"
|
||||
|
||||
var (
|
||||
label *models.Label
|
||||
label *issues_model.Label
|
||||
err error
|
||||
)
|
||||
strID := ctx.Params(":id")
|
||||
if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil {
|
||||
label, err = models.GetLabelInOrgByName(ctx, ctx.Org.Organization.ID, strID)
|
||||
label, err = issues_model.GetLabelInOrgByName(ctx, ctx.Org.Organization.ID, strID)
|
||||
} else {
|
||||
label, err = models.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, intID)
|
||||
label, err = issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, intID)
|
||||
}
|
||||
if err != nil {
|
||||
if models.IsErrOrgLabelNotExist(err) {
|
||||
if issues_model.IsErrOrgLabelNotExist(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "GetLabelByOrgID", err)
|
||||
|
@ -183,9 +183,9 @@ func EditLabel(ctx *context.APIContext) {
|
|||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
form := web.GetForm(ctx).(*api.EditLabelOption)
|
||||
label, err := models.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.ParamsInt64(":id"))
|
||||
label, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if models.IsErrOrgLabelNotExist(err) {
|
||||
if issues_model.IsErrOrgLabelNotExist(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "GetLabelByRepoID", err)
|
||||
|
@ -201,7 +201,7 @@ func EditLabel(ctx *context.APIContext) {
|
|||
if len(label.Color) == 6 {
|
||||
label.Color = "#" + label.Color
|
||||
}
|
||||
if !models.LabelColorPattern.MatchString(label.Color) {
|
||||
if !issues_model.LabelColorPattern.MatchString(label.Color) {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "ColorPattern", fmt.Errorf("bad color code: %s", label.Color))
|
||||
return
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ func EditLabel(ctx *context.APIContext) {
|
|||
if form.Description != nil {
|
||||
label.Description = *form.Description
|
||||
}
|
||||
if err := models.UpdateLabel(label); err != nil {
|
||||
if err := issues_model.UpdateLabel(label); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "UpdateLabel", err)
|
||||
return
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ func DeleteLabel(ctx *context.APIContext) {
|
|||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
|
||||
if err := models.DeleteLabel(ctx.Org.Organization.ID, ctx.ParamsInt64(":id")); err != nil {
|
||||
if err := issues_model.DeleteLabel(ctx.Org.Organization.ID, ctx.ParamsInt64(":id")); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "DeleteLabel", err)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue