mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-23 14:00:03 +02:00
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
|
@ -7,8 +7,8 @@ package repo
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/models/organization"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
|
@ -56,7 +56,7 @@ func InitializeLabels(ctx *context.Context) {
|
|||
|
||||
// RetrieveLabels find all the labels of a repository and organization
|
||||
func RetrieveLabels(ctx *context.Context) {
|
||||
labels, err := models.GetLabelsByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormString("sort"), db.ListOptions{})
|
||||
labels, err := issues_model.GetLabelsByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormString("sort"), db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("RetrieveLabels.GetLabels", err)
|
||||
return
|
||||
|
@ -69,7 +69,7 @@ func RetrieveLabels(ctx *context.Context) {
|
|||
ctx.Data["Labels"] = labels
|
||||
|
||||
if ctx.Repo.Owner.IsOrganization() {
|
||||
orgLabels, err := models.GetLabelsByOrgID(ctx, ctx.Repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
|
||||
orgLabels, err := issues_model.GetLabelsByOrgID(ctx, ctx.Repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLabelsByOrgID", err)
|
||||
return
|
||||
|
@ -111,13 +111,13 @@ func NewLabel(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
l := &models.Label{
|
||||
l := &issues_model.Label{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
Name: form.Title,
|
||||
Description: form.Description,
|
||||
Color: form.Color,
|
||||
}
|
||||
if err := models.NewLabel(ctx, l); err != nil {
|
||||
if err := issues_model.NewLabel(ctx, l); err != nil {
|
||||
ctx.ServerError("NewLabel", err)
|
||||
return
|
||||
}
|
||||
|
@ -127,10 +127,10 @@ func NewLabel(ctx *context.Context) {
|
|||
// UpdateLabel update a label's name and color
|
||||
func UpdateLabel(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*forms.CreateLabelForm)
|
||||
l, err := models.GetLabelInRepoByID(ctx, ctx.Repo.Repository.ID, form.ID)
|
||||
l, err := issues_model.GetLabelInRepoByID(ctx, ctx.Repo.Repository.ID, form.ID)
|
||||
if err != nil {
|
||||
switch {
|
||||
case models.IsErrRepoLabelNotExist(err):
|
||||
case issues_model.IsErrRepoLabelNotExist(err):
|
||||
ctx.Error(http.StatusNotFound)
|
||||
default:
|
||||
ctx.ServerError("UpdateLabel", err)
|
||||
|
@ -141,7 +141,7 @@ func UpdateLabel(ctx *context.Context) {
|
|||
l.Name = form.Title
|
||||
l.Description = form.Description
|
||||
l.Color = form.Color
|
||||
if err := models.UpdateLabel(l); err != nil {
|
||||
if err := issues_model.UpdateLabel(l); err != nil {
|
||||
ctx.ServerError("UpdateLabel", err)
|
||||
return
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ func UpdateLabel(ctx *context.Context) {
|
|||
|
||||
// DeleteLabel delete a label
|
||||
func DeleteLabel(ctx *context.Context) {
|
||||
if err := models.DeleteLabel(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
if err := issues_model.DeleteLabel(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteLabel: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
|
||||
|
@ -177,9 +177,9 @@ func UpdateIssueLabel(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
case "attach", "detach", "toggle":
|
||||
label, err := models.GetLabelByID(ctx, ctx.FormInt64("id"))
|
||||
label, err := issues_model.GetLabelByID(ctx, ctx.FormInt64("id"))
|
||||
if err != nil {
|
||||
if models.IsErrRepoLabelNotExist(err) {
|
||||
if issues_model.IsErrRepoLabelNotExist(err) {
|
||||
ctx.Error(http.StatusNotFound, "GetLabelByID")
|
||||
} else {
|
||||
ctx.ServerError("GetLabelByID", err)
|
||||
|
@ -191,7 +191,7 @@ func UpdateIssueLabel(ctx *context.Context) {
|
|||
// detach if any issues already have label, otherwise attach
|
||||
action = "attach"
|
||||
for _, issue := range issues {
|
||||
if models.HasIssueLabel(ctx, issue.ID, label.ID) {
|
||||
if issues_model.HasIssueLabel(ctx, issue.ID, label.ID) {
|
||||
action = "detach"
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue