more formatting fixes

This commit is contained in:
Denys Konovalov 2024-01-21 15:39:55 +01:00
parent 24babd6ca1
commit 58e56cd0c6
No known key found for this signature in database
GPG Key ID: 0037E1B0E33BD2C9
2 changed files with 14 additions and 25 deletions

View File

@ -15,10 +15,7 @@ import (
"code.gitea.io/gitea/services/convert" "code.gitea.io/gitea/services/convert"
) )
func innerCreateProject( func innerCreateProject(ctx *context.APIContext, projectType project_model.Type) {
ctx *context.APIContext,
projectType project_model.Type,
) {
form := web.GetForm(ctx).(*api.NewProjectPayload) form := web.GetForm(ctx).(*api.NewProjectPayload)
project := &project_model.Project{ project := &project_model.Project{
RepoID: 0, RepoID: 0,
@ -287,12 +284,10 @@ func ListUserProjects(ctx *context.APIContext) {
// "404": // "404":
// "$ref": "#/responses/notFound" // "$ref": "#/responses/notFound"
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{ projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
Type: project_model.TypeIndividual, Type: project_model.TypeIndividual,
IsClosed: ctx.FormOptionalBool("closed"), IsClosed: ctx.FormOptionalBool("closed"),
OwnerID: ctx.Doer.ID, OwnerID: ctx.Doer.ID,
ListOptions: db.ListOptions{ ListOptions: db.ListOptions{Page: ctx.FormInt("page")},
Page: ctx.FormInt("page"),
},
}) })
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "Projects", err) ctx.Error(http.StatusInternalServerError, "Projects", err)
@ -343,12 +338,10 @@ func ListOrgProjects(ctx *context.APIContext) {
// "404": // "404":
// "$ref": "#/responses/notFound" // "$ref": "#/responses/notFound"
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{ projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
OwnerID: ctx.Org.Organization.AsUser().ID, OwnerID: ctx.Org.Organization.AsUser().ID,
ListOptions: db.ListOptions{ ListOptions: db.ListOptions{Page: ctx.FormInt("page")},
Page: ctx.FormInt("page"), IsClosed: ctx.FormOptionalBool("closed"),
}, Type: project_model.TypeOrganization,
IsClosed: ctx.FormOptionalBool("closed"),
Type: project_model.TypeOrganization,
}) })
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "Projects", err) ctx.Error(http.StatusInternalServerError, "Projects", err)
@ -404,12 +397,10 @@ func ListRepoProjects(ctx *context.APIContext) {
// "404": // "404":
// "$ref": "#/responses/notFound" // "$ref": "#/responses/notFound"
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{ projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
IsClosed: ctx.FormOptionalBool("closed"), IsClosed: ctx.FormOptionalBool("closed"),
Type: project_model.TypeRepository, Type: project_model.TypeRepository,
ListOptions: db.ListOptions{ ListOptions: db.ListOptions{Page: ctx.FormInt("page")},
Page: ctx.FormInt("page"),
},
}) })
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "Projects", err) ctx.Error(http.StatusInternalServerError, "Projects", err)

View File

@ -149,9 +149,7 @@ func TestAPIUpdateProject(t *testing.T) {
token := getUserToken(t, "user2", auth_model.AccessTokenScopeWriteUser, auth_model.AccessTokenScopeWriteIssue) token := getUserToken(t, "user2", auth_model.AccessTokenScopeWriteUser, auth_model.AccessTokenScopeWriteIssue)
link, _ := url.Parse(fmt.Sprintf("/api/v1/projects/%d", 1)) link, _ := url.Parse(fmt.Sprintf("/api/v1/projects/%d", 1))
req := NewRequestWithJSON(t, "PATCH", link.String(), &api.UpdateProjectPayload{ req := NewRequestWithJSON(t, "PATCH", link.String(), &api.UpdateProjectPayload{Title: "First project updated"}).AddTokenAuth(token)
Title: "First project updated",
}).AddTokenAuth(token)
var apiProject *api.Project var apiProject *api.Project