mirror of
https://github.com/go-gitea/gitea.git
synced 2025-08-07 23:58:50 +00:00
some renames
This commit is contained in:
parent
d7466683a4
commit
9c4937f135
@ -34,6 +34,28 @@ const (
|
|||||||
CardTypeImagesAndText
|
CardTypeImagesAndText
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (p CardType) ToString() string {
|
||||||
|
switch p {
|
||||||
|
case CardTypeImagesAndText:
|
||||||
|
return "ImagesAndText"
|
||||||
|
case CardTypeTextOnly:
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
return "TextOnly"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ToCardType(s string) CardType {
|
||||||
|
switch s {
|
||||||
|
case "ImagesAndText":
|
||||||
|
return CardTypeImagesAndText
|
||||||
|
case "TextOnly":
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
return CardTypeTextOnly
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ColumnColorPattern is a regexp witch can validate ColumnColor
|
// ColumnColorPattern is a regexp witch can validate ColumnColor
|
||||||
var ColumnColorPattern = regexp.MustCompile("^#[0-9a-fA-F]{6}$")
|
var ColumnColorPattern = regexp.MustCompile("^#[0-9a-fA-F]{6}$")
|
||||||
|
|
||||||
|
@ -25,6 +25,31 @@ const (
|
|||||||
TemplateTypeBugTriage
|
TemplateTypeBugTriage
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (p TemplateType) ToString() string {
|
||||||
|
switch p {
|
||||||
|
case TemplateTypeBasicKanban:
|
||||||
|
return "BasicKanban"
|
||||||
|
case TemplateTypeBugTriage:
|
||||||
|
return "BugTriage"
|
||||||
|
case TemplateTypeNone:
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToTemplateType converts a string to a TemplateType
|
||||||
|
func ToTemplateType(s string) TemplateType {
|
||||||
|
switch s {
|
||||||
|
case "BasicKanban":
|
||||||
|
return TemplateTypeBasicKanban
|
||||||
|
case "BugTriage":
|
||||||
|
return TemplateTypeBugTriage
|
||||||
|
default:
|
||||||
|
return TemplateTypeNone
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GetTemplateConfigs retrieves the template configs of configurations project columns could have
|
// GetTemplateConfigs retrieves the template configs of configurations project columns could have
|
||||||
func GetTemplateConfigs() []TemplateConfig {
|
func GetTemplateConfigs() []TemplateConfig {
|
||||||
return []TemplateConfig{
|
return []TemplateConfig{
|
||||||
|
@ -5,37 +5,53 @@ package structs
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
|
// NewProjectOption options when creating a new project
|
||||||
// swagger:model
|
// swagger:model
|
||||||
type NewProjectPayload struct {
|
type NewProjectOption struct {
|
||||||
// required:true
|
// required:true
|
||||||
Title string `json:"title" binding:"Required"`
|
// Keep compatibility with Github API to use "name" instead of "title"
|
||||||
|
Name string `json:"name" binding:"Required"`
|
||||||
// required:true
|
// required:true
|
||||||
BoardType uint8 `json:"board_type"`
|
// enum: , BasicKanban, BugTriage
|
||||||
|
// Note: this is the same as TemplateType in models/project/template.go
|
||||||
|
TemplateType string `json:"template_type"`
|
||||||
// required:true
|
// required:true
|
||||||
CardType uint8 `json:"card_type"`
|
// enum: TextOnly, ImagesAndText
|
||||||
Description string `json:"description"`
|
CardType string `json:"card_type"`
|
||||||
|
// Keep compatibility with Github API to use "body" instead of "description"
|
||||||
|
Body string `json:"body"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateProjectOption options when updating a project
|
||||||
// swagger:model
|
// swagger:model
|
||||||
type UpdateProjectPayload struct {
|
type UpdateProjectOption struct {
|
||||||
// required:true
|
// required:true
|
||||||
Title string `json:"title" binding:"Required"`
|
// Keep compatibility with Github API to use "name" instead of "title"
|
||||||
Description string `json:"description"`
|
Name string `json:"name" binding:"Required"`
|
||||||
|
// Keep compatibility with Github API to use "body" instead of "description"
|
||||||
|
Body string `json:"body"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Project represents a project
|
||||||
// swagger:model
|
// swagger:model
|
||||||
type Project struct {
|
type Project struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Title string `json:"title"`
|
// Keep compatibility with Github API to use "name" instead of "title"
|
||||||
Description string `json:"description"`
|
Name string `json:"name"`
|
||||||
TemplateType uint8 `json:"board_type"`
|
// Keep compatibility with Github API to use "body" instead of "description"
|
||||||
IsClosed bool `json:"is_closed"`
|
Body string `json:"body"`
|
||||||
|
// required:true
|
||||||
|
// enum: , BasicKanban, BugTriage
|
||||||
|
// Note: this is the same as TemplateType in models/project/template.go
|
||||||
|
TemplateType string `json:"template_type"`
|
||||||
|
// enum: open, closed
|
||||||
|
State string `json:"state"`
|
||||||
// swagger:strfmt date-time
|
// swagger:strfmt date-time
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
// swagger:strfmt date-time
|
// swagger:strfmt date-time
|
||||||
Updated time.Time `json:"updated_at"`
|
Updated time.Time `json:"updated_at"`
|
||||||
// swagger:strfmt date-time
|
// swagger:strfmt date-time
|
||||||
Closed time.Time `json:"closed_at"`
|
Closed *time.Time `json:"closed_at"`
|
||||||
|
|
||||||
Repo *RepositoryMeta `json:"repository"`
|
Repo *RepositoryMeta `json:"repository"`
|
||||||
Creator *User `json:"creator"`
|
Creator *User `json:"creator"`
|
||||||
|
@ -1165,7 +1165,7 @@ func Routes() *web.Router {
|
|||||||
|
|
||||||
m.Group("/projects", func() {
|
m.Group("/projects", func() {
|
||||||
m.Get("", projects.ListUserProjects)
|
m.Get("", projects.ListUserProjects)
|
||||||
m.Post("", bind(api.NewProjectPayload{}), projects.CreateUserProject)
|
m.Post("", bind(api.NewProjectOption{}), projects.CreateUserProject)
|
||||||
})
|
})
|
||||||
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryUser), reqToken())
|
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryUser), reqToken())
|
||||||
|
|
||||||
@ -1475,7 +1475,7 @@ func Routes() *web.Router {
|
|||||||
m.Methods("HEAD,GET", "/{ball_type:tarball|zipball|bundle}/*", reqRepoReader(unit.TypeCode), repo.DownloadArchive)
|
m.Methods("HEAD,GET", "/{ball_type:tarball|zipball|bundle}/*", reqRepoReader(unit.TypeCode), repo.DownloadArchive)
|
||||||
|
|
||||||
m.Group("/projects", func() {
|
m.Group("/projects", func() {
|
||||||
m.Post("", bind(api.NewProjectPayload{}), projects.CreateRepoProject)
|
m.Post("", bind(api.NewProjectOption{}), projects.CreateRepoProject)
|
||||||
})
|
})
|
||||||
}, repoAssignment(), checkTokenPublicOnly())
|
}, repoAssignment(), checkTokenPublicOnly())
|
||||||
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryRepository))
|
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryRepository))
|
||||||
@ -1699,7 +1699,7 @@ func Routes() *web.Router {
|
|||||||
}, reqToken(), reqOrgOwnership())
|
}, reqToken(), reqOrgOwnership())
|
||||||
|
|
||||||
m.Group("/projects", func() {
|
m.Group("/projects", func() {
|
||||||
m.Post("", bind(api.NewProjectPayload{}), projects.CreateOrgProject)
|
m.Post("", bind(api.NewProjectOption{}), projects.CreateOrgProject)
|
||||||
})
|
})
|
||||||
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryOrganization), orgAssignment(true), checkTokenPublicOnly())
|
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryOrganization), orgAssignment(true), checkTokenPublicOnly())
|
||||||
m.Group("/teams/{teamid}", func() {
|
m.Group("/teams/{teamid}", func() {
|
||||||
|
@ -16,20 +16,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func innerCreateProject(ctx *context.APIContext, projectType project_model.Type) {
|
func innerCreateProject(ctx *context.APIContext, projectType project_model.Type) {
|
||||||
form := web.GetForm(ctx).(*api.NewProjectPayload)
|
form := web.GetForm(ctx).(*api.NewProjectOption)
|
||||||
project := &project_model.Project{
|
project := &project_model.Project{
|
||||||
RepoID: 0,
|
Title: form.Name,
|
||||||
OwnerID: ctx.Doer.ID,
|
Description: form.Body,
|
||||||
Title: form.Title,
|
|
||||||
Description: form.Description,
|
|
||||||
CreatorID: ctx.Doer.ID,
|
CreatorID: ctx.Doer.ID,
|
||||||
TemplateType: project_model.TemplateType(form.BoardType),
|
TemplateType: project_model.ToTemplateType(form.TemplateType),
|
||||||
Type: projectType,
|
Type: projectType,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.ContextUser != nil {
|
if ctx.ContextUser == nil {
|
||||||
project.OwnerID = ctx.ContextUser.ID
|
ctx.APIError(http.StatusForbidden, "Not authenticated")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
project.OwnerID = ctx.ContextUser.ID
|
||||||
|
|
||||||
if projectType == project_model.TypeRepository {
|
if projectType == project_model.TypeRepository {
|
||||||
project.RepoID = ctx.Repo.Repository.ID
|
project.RepoID = ctx.Repo.Repository.ID
|
||||||
@ -67,7 +67,7 @@ func CreateUserProject(ctx *context.APIContext) {
|
|||||||
// - name: project
|
// - name: project
|
||||||
// in: body
|
// in: body
|
||||||
// required: true
|
// required: true
|
||||||
// schema: { "$ref": "#/definitions/NewProjectPayload" }
|
// schema: { "$ref": "#/definitions/NewProjectOption" }
|
||||||
// responses:
|
// responses:
|
||||||
// "201":
|
// "201":
|
||||||
// "$ref": "#/responses/Project"
|
// "$ref": "#/responses/Project"
|
||||||
@ -95,7 +95,7 @@ func CreateOrgProject(ctx *context.APIContext) {
|
|||||||
// - name: project
|
// - name: project
|
||||||
// in: body
|
// in: body
|
||||||
// required: true
|
// required: true
|
||||||
// schema: { "$ref": "#/definitions/NewProjectPayload" }
|
// schema: { "$ref": "#/definitions/NewProjectOption" }
|
||||||
// responses:
|
// responses:
|
||||||
// "201":
|
// "201":
|
||||||
// "$ref": "#/responses/Project"
|
// "$ref": "#/responses/Project"
|
||||||
@ -128,7 +128,7 @@ func CreateRepoProject(ctx *context.APIContext) {
|
|||||||
// - name: project
|
// - name: project
|
||||||
// in: body
|
// in: body
|
||||||
// required: true
|
// required: true
|
||||||
// schema: { "$ref": "#/definitions/NewProjectPayload" }
|
// schema: { "$ref": "#/definitions/NewProjectOption" }
|
||||||
// responses:
|
// responses:
|
||||||
// "201":
|
// "201":
|
||||||
// "$ref": "#/responses/Project"
|
// "$ref": "#/responses/Project"
|
||||||
@ -158,7 +158,7 @@ func GetProject(ctx *context.APIContext) {
|
|||||||
// "$ref": "#/responses/forbidden"
|
// "$ref": "#/responses/forbidden"
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
project, err := project_model.GetProjectByID(ctx, ctx.FormInt64(":id"))
|
project, err := project_model.GetProjectByID(ctx, ctx.FormInt64("id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if project_model.IsErrProjectNotExist(err) {
|
if project_model.IsErrProjectNotExist(err) {
|
||||||
ctx.APIError(http.StatusNotFound, err)
|
ctx.APIError(http.StatusNotFound, err)
|
||||||
@ -193,7 +193,7 @@ func UpdateProject(ctx *context.APIContext) {
|
|||||||
// - name: project
|
// - name: project
|
||||||
// in: body
|
// in: body
|
||||||
// required: true
|
// required: true
|
||||||
// schema: { "$ref": "#/definitions/UpdateProjectPayload" }
|
// schema: { "$ref": "#/definitions/UpdateProjectOption" }
|
||||||
// responses:
|
// responses:
|
||||||
// "200":
|
// "200":
|
||||||
// "$ref": "#/responses/Project"
|
// "$ref": "#/responses/Project"
|
||||||
@ -201,7 +201,7 @@ func UpdateProject(ctx *context.APIContext) {
|
|||||||
// "$ref": "#/responses/forbidden"
|
// "$ref": "#/responses/forbidden"
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
form := web.GetForm(ctx).(*api.UpdateProjectPayload)
|
form := web.GetForm(ctx).(*api.UpdateProjectOption)
|
||||||
project, err := project_model.GetProjectByID(ctx, ctx.FormInt64("id"))
|
project, err := project_model.GetProjectByID(ctx, ctx.FormInt64("id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if project_model.IsErrProjectNotExist(err) {
|
if project_model.IsErrProjectNotExist(err) {
|
||||||
@ -211,11 +211,11 @@ func UpdateProject(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if project.Title != form.Title {
|
if project.Title != form.Name {
|
||||||
project.Title = form.Title
|
project.Title = form.Name
|
||||||
}
|
}
|
||||||
if project.Description != form.Description {
|
if project.Description != form.Body {
|
||||||
project.Description = form.Description
|
project.Description = form.Body
|
||||||
}
|
}
|
||||||
|
|
||||||
err = project_model.UpdateProject(ctx, project)
|
err = project_model.UpdateProject(ctx, project)
|
||||||
@ -249,7 +249,7 @@ func DeleteProject(ctx *context.APIContext) {
|
|||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
if err := project_model.DeleteProjectByID(ctx, ctx.FormInt64(":id")); err != nil {
|
if err := project_model.DeleteProjectByID(ctx, ctx.FormInt64("id")); err != nil {
|
||||||
ctx.APIErrorInternal(err)
|
ctx.APIErrorInternal(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -221,9 +221,11 @@ type swaggerParameterBodies struct {
|
|||||||
UpdateVariableOption api.UpdateVariableOption
|
UpdateVariableOption api.UpdateVariableOption
|
||||||
|
|
||||||
// in:body
|
// in:body
|
||||||
NewProjectPayload api.NewProjectPayload
|
LockIssueOption api.LockIssueOption
|
||||||
|
|
||||||
// in:body
|
// in:body
|
||||||
UpdateProjectPayload api.UpdateProjectPayload
|
NewProjectOption api.NewProjectOption
|
||||||
LockIssueOption api.LockIssueOption
|
|
||||||
|
// in:body
|
||||||
|
UpdateProjectOption api.UpdateProjectOption
|
||||||
}
|
}
|
||||||
|
@ -8,17 +8,21 @@ import (
|
|||||||
|
|
||||||
project_model "code.gitea.io/gitea/models/project"
|
project_model "code.gitea.io/gitea/models/project"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ToAPIProject(ctx context.Context, project *project_model.Project) (*api.Project, error) {
|
func ToAPIProject(ctx context.Context, project *project_model.Project) (*api.Project, error) {
|
||||||
apiProject := &api.Project{
|
apiProject := &api.Project{
|
||||||
Title: project.Title,
|
Name: project.Title,
|
||||||
Description: project.Description,
|
Body: project.Description,
|
||||||
TemplateType: uint8(project.TemplateType),
|
TemplateType: project.TemplateType.ToString(),
|
||||||
IsClosed: project.IsClosed,
|
State: util.Iif(project.IsClosed, "closed", "open"),
|
||||||
Created: project.CreatedUnix.AsTime(),
|
Created: project.CreatedUnix.AsTime(),
|
||||||
Updated: project.UpdatedUnix.AsTime(),
|
Updated: project.UpdatedUnix.AsTime(),
|
||||||
Closed: project.ClosedDateUnix.AsTime(),
|
}
|
||||||
|
if !project.ClosedDateUnix.IsZero() {
|
||||||
|
tm := project.ClosedDateUnix.AsTime()
|
||||||
|
apiProject.Closed = &tm
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := project.LoadRepo(ctx); err != nil {
|
if err := project.LoadRepo(ctx); err != nil {
|
||||||
|
87
templates/swagger/v1_json.tmpl
generated
87
templates/swagger/v1_json.tmpl
generated
@ -26383,28 +26383,36 @@
|
|||||||
"NewProjectPayload": {
|
"NewProjectPayload": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"title",
|
"name",
|
||||||
"board_type",
|
"template_type",
|
||||||
"card_type"
|
"card_type"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"board_type": {
|
"body": {
|
||||||
"type": "integer",
|
"description": "Keep compatibility with Github API to use \"body\" instead of \"description\"",
|
||||||
"format": "uint8",
|
|
||||||
"x-go-name": "BoardType"
|
|
||||||
},
|
|
||||||
"card_type": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint8",
|
|
||||||
"x-go-name": "CardType"
|
|
||||||
},
|
|
||||||
"description": {
|
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Description"
|
"x-go-name": "Description"
|
||||||
},
|
},
|
||||||
"title": {
|
"card_type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"TextOnly",
|
||||||
|
" ImagesAndText"
|
||||||
|
],
|
||||||
|
"x-go-name": "CardType"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Title"
|
"x-go-name": "Title"
|
||||||
|
},
|
||||||
|
"template_type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"",
|
||||||
|
" BasicKanban",
|
||||||
|
" BugTriage"
|
||||||
|
],
|
||||||
|
"x-go-name": "TemplateType"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
@ -26983,11 +26991,14 @@
|
|||||||
},
|
},
|
||||||
"Project": {
|
"Project": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"template_type"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"board_type": {
|
"body": {
|
||||||
"type": "integer",
|
"description": "Keep compatibility with Github API to use \"body\" instead of \"description\"",
|
||||||
"format": "uint8",
|
"type": "string",
|
||||||
"x-go-name": "TemplateType"
|
"x-go-name": "Description"
|
||||||
},
|
},
|
||||||
"closed_at": {
|
"closed_at": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -27002,18 +27013,15 @@
|
|||||||
"creator": {
|
"creator": {
|
||||||
"$ref": "#/definitions/User"
|
"$ref": "#/definitions/User"
|
||||||
},
|
},
|
||||||
"description": {
|
|
||||||
"type": "string",
|
|
||||||
"x-go-name": "Description"
|
|
||||||
},
|
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64",
|
"format": "int64",
|
||||||
"x-go-name": "ID"
|
"x-go-name": "ID"
|
||||||
},
|
},
|
||||||
"is_closed": {
|
"name": {
|
||||||
"type": "boolean",
|
"description": "Keep compatibility with Github API to use \"name\" instead of \"title\"",
|
||||||
"x-go-name": "IsClosed"
|
"type": "string",
|
||||||
|
"x-go-name": "Title"
|
||||||
},
|
},
|
||||||
"owner": {
|
"owner": {
|
||||||
"$ref": "#/definitions/User"
|
"$ref": "#/definitions/User"
|
||||||
@ -27021,9 +27029,22 @@
|
|||||||
"repository": {
|
"repository": {
|
||||||
"$ref": "#/definitions/RepositoryMeta"
|
"$ref": "#/definitions/RepositoryMeta"
|
||||||
},
|
},
|
||||||
"title": {
|
"state": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Title"
|
"enum": [
|
||||||
|
"open",
|
||||||
|
" closed"
|
||||||
|
],
|
||||||
|
"x-go-name": "State"
|
||||||
|
},
|
||||||
|
"template_type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"",
|
||||||
|
" BasicKanban",
|
||||||
|
" BugTriage"
|
||||||
|
],
|
||||||
|
"x-go-name": "TemplateType"
|
||||||
},
|
},
|
||||||
"updated_at": {
|
"updated_at": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -28590,14 +28611,15 @@
|
|||||||
"UpdateProjectPayload": {
|
"UpdateProjectPayload": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"title"
|
"name"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"description": {
|
"body": {
|
||||||
|
"description": "Keep compatibility with Github API to use \"body\" instead of \"description\"",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Description"
|
"x-go-name": "Description"
|
||||||
},
|
},
|
||||||
"title": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Title"
|
"x-go-name": "Title"
|
||||||
}
|
}
|
||||||
@ -30150,10 +30172,7 @@
|
|||||||
"parameterBodies": {
|
"parameterBodies": {
|
||||||
"description": "parameterBodies",
|
"description": "parameterBodies",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/LockIssueOption"
|
"$ref": "#/definitions/UpdateProjectPayload"
|
||||||
},
|
|
||||||
"headers": {
|
|
||||||
"LockIssueOption": {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"redirect": {
|
"redirect": {
|
||||||
|
@ -20,67 +20,70 @@ import (
|
|||||||
|
|
||||||
func TestAPICreateUserProject(t *testing.T) {
|
func TestAPICreateUserProject(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
const title, description, boardType = "project_name", "project_description", uint8(project_model.TemplateTypeBasicKanban)
|
const title, description = "project_name", "project_description"
|
||||||
|
templateType := project_model.TemplateTypeBasicKanban.ToString()
|
||||||
|
|
||||||
token := getUserToken(t, "user2", auth_model.AccessTokenScopeWriteIssue, auth_model.AccessTokenScopeWriteUser)
|
token := getUserToken(t, "user2", auth_model.AccessTokenScopeWriteIssue, auth_model.AccessTokenScopeWriteUser)
|
||||||
|
|
||||||
req := NewRequestWithJSON(t, "POST", "/api/v1/user/projects", &api.NewProjectPayload{
|
req := NewRequestWithJSON(t, "POST", "/api/v1/user/projects", &api.NewProjectOption{
|
||||||
Title: title,
|
Name: title,
|
||||||
Description: description,
|
Body: description,
|
||||||
BoardType: boardType,
|
TemplateType: templateType,
|
||||||
}).AddTokenAuth(token)
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusCreated)
|
resp := MakeRequest(t, req, http.StatusCreated)
|
||||||
var apiProject api.Project
|
var apiProject api.Project
|
||||||
DecodeJSON(t, resp, &apiProject)
|
DecodeJSON(t, resp, &apiProject)
|
||||||
assert.Equal(t, title, apiProject.Title)
|
assert.Equal(t, title, apiProject.Name)
|
||||||
assert.Equal(t, description, apiProject.Description)
|
assert.Equal(t, description, apiProject.Body)
|
||||||
assert.Equal(t, boardType, apiProject.TemplateType)
|
assert.Equal(t, templateType, apiProject.TemplateType)
|
||||||
assert.Equal(t, "user2", apiProject.Creator.UserName)
|
assert.Equal(t, "user2", apiProject.Creator.UserName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPICreateOrgProject(t *testing.T) {
|
func TestAPICreateOrgProject(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
const title, description, boardType = "project_name", "project_description", uint8(project_model.TemplateTypeBasicKanban)
|
const title, description = "project_name", "project_description"
|
||||||
|
templateType := project_model.TemplateTypeBasicKanban.ToString()
|
||||||
|
|
||||||
orgName := "org17"
|
orgName := "org17"
|
||||||
token := getUserToken(t, "user2", auth_model.AccessTokenScopeWriteIssue, auth_model.AccessTokenScopeWriteOrganization)
|
token := getUserToken(t, "user2", auth_model.AccessTokenScopeWriteIssue, auth_model.AccessTokenScopeWriteOrganization)
|
||||||
urlStr := fmt.Sprintf("/api/v1/orgs/%s/projects", orgName)
|
urlStr := fmt.Sprintf("/api/v1/orgs/%s/projects", orgName)
|
||||||
|
|
||||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.NewProjectPayload{
|
req := NewRequestWithJSON(t, "POST", urlStr, &api.NewProjectOption{
|
||||||
Title: title,
|
Name: title,
|
||||||
Description: description,
|
Body: description,
|
||||||
BoardType: boardType,
|
TemplateType: templateType,
|
||||||
}).AddTokenAuth(token)
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusCreated)
|
resp := MakeRequest(t, req, http.StatusCreated)
|
||||||
var apiProject api.Project
|
var apiProject api.Project
|
||||||
DecodeJSON(t, resp, &apiProject)
|
DecodeJSON(t, resp, &apiProject)
|
||||||
assert.Equal(t, title, apiProject.Title)
|
assert.Equal(t, title, apiProject.Name)
|
||||||
assert.Equal(t, description, apiProject.Description)
|
assert.Equal(t, description, apiProject.Body)
|
||||||
assert.Equal(t, boardType, apiProject.TemplateType)
|
assert.Equal(t, templateType, apiProject.TemplateType)
|
||||||
assert.Equal(t, "user2", apiProject.Creator.UserName)
|
assert.Equal(t, "user2", apiProject.Creator.UserName)
|
||||||
assert.Equal(t, "org17", apiProject.Owner.UserName)
|
assert.Equal(t, "org17", apiProject.Owner.UserName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPICreateRepoProject(t *testing.T) {
|
func TestAPICreateRepoProject(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
const title, description, boardType = "project_name", "project_description", uint8(project_model.TemplateTypeBasicKanban)
|
const title, description = "project_name", "project_description"
|
||||||
|
templateType := project_model.TemplateTypeBasicKanban.ToString()
|
||||||
|
|
||||||
ownerName := "user2"
|
ownerName := "user2"
|
||||||
repoName := "repo1"
|
repoName := "repo1"
|
||||||
token := getUserToken(t, ownerName, auth_model.AccessTokenScopeWriteIssue, auth_model.AccessTokenScopeWriteOrganization)
|
token := getUserToken(t, ownerName, auth_model.AccessTokenScopeWriteIssue, auth_model.AccessTokenScopeWriteOrganization)
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/projects", ownerName, repoName)
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/projects", ownerName, repoName)
|
||||||
|
|
||||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.NewProjectPayload{
|
req := NewRequestWithJSON(t, "POST", urlStr, &api.NewProjectOption{
|
||||||
Title: title,
|
Name: title,
|
||||||
Description: description,
|
Body: description,
|
||||||
BoardType: boardType,
|
TemplateType: templateType,
|
||||||
}).AddTokenAuth(token)
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusCreated)
|
resp := MakeRequest(t, req, http.StatusCreated)
|
||||||
var apiProject api.Project
|
var apiProject api.Project
|
||||||
DecodeJSON(t, resp, &apiProject)
|
DecodeJSON(t, resp, &apiProject)
|
||||||
assert.Equal(t, title, apiProject.Title)
|
assert.Equal(t, title, apiProject.Name)
|
||||||
assert.Equal(t, description, apiProject.Description)
|
assert.Equal(t, description, apiProject.Body)
|
||||||
assert.Equal(t, boardType, apiProject.TemplateType)
|
assert.Equal(t, templateType, apiProject.TemplateType)
|
||||||
assert.Equal(t, "repo1", apiProject.Repo.Name)
|
assert.Equal(t, "repo1", apiProject.Repo.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +142,7 @@ func TestAPIGetProject(t *testing.T) {
|
|||||||
|
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
DecodeJSON(t, resp, &apiProject)
|
DecodeJSON(t, resp, &apiProject)
|
||||||
assert.Equal(t, "First project", apiProject.Title)
|
assert.Equal(t, "First project", apiProject.Name)
|
||||||
assert.Equal(t, "repo1", apiProject.Repo.Name)
|
assert.Equal(t, "repo1", apiProject.Repo.Name)
|
||||||
assert.Equal(t, "user2", apiProject.Creator.UserName)
|
assert.Equal(t, "user2", apiProject.Creator.UserName)
|
||||||
}
|
}
|
||||||
@ -149,13 +152,13 @@ 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{Title: "First project updated"}).AddTokenAuth(token)
|
req := NewRequestWithJSON(t, "PATCH", link.String(), &api.UpdateProjectOption{Name: "First project updated"}).AddTokenAuth(token)
|
||||||
|
|
||||||
var apiProject *api.Project
|
var apiProject *api.Project
|
||||||
|
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
DecodeJSON(t, resp, &apiProject)
|
DecodeJSON(t, resp, &apiProject)
|
||||||
assert.Equal(t, "First project updated", apiProject.Title)
|
assert.Equal(t, "First project updated", apiProject.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPIDeleteProject(t *testing.T) {
|
func TestAPIDeleteProject(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user