mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
feat: add projects/ endpoint for initiating extension of api
This commit is contained in:
@@ -864,6 +864,36 @@ func Routes() *web.Router {
|
||||
})
|
||||
}
|
||||
|
||||
m.Group("/{username}", func() {
|
||||
m.Group("/projects", func() {
|
||||
// m.Group("", func() {
|
||||
// m.Get("", org.Projects)
|
||||
// m.Get("/{id}", org.ViewProject)
|
||||
// }, reqUnitAccess(unit.TypeProjects, perm.AccessModeRead, true))
|
||||
m.Group("", func() { //nolint:dupl
|
||||
// m.Get("/new", org.RenderNewProject)
|
||||
m.Post("", bind(api.CreateProjectOption{}), org.CreateProject)
|
||||
// m.Group("/{id}", func() {
|
||||
// m.Post("", web.Bind(forms.EditProjectColumnForm{}), org.AddColumnToProjectPost)
|
||||
// m.Post("/move", project.MoveColumns)
|
||||
// m.Post("/delete", org.DeleteProject)
|
||||
|
||||
// m.Get("/edit", org.RenderEditProject)
|
||||
// m.Post("/edit", web.Bind(forms.CreateProjectForm{}), org.EditProjectPost)
|
||||
// m.Post("/{action:open|close}", org.ChangeProjectStatus)
|
||||
|
||||
// m.Group("/{columnID}", func() {
|
||||
// m.Put("", web.Bind(forms.EditProjectColumnForm{}), org.EditProjectColumn)
|
||||
// m.Delete("", org.DeleteProjectColumn)
|
||||
// m.Post("/default", org.SetDefaultProjectColumn)
|
||||
// m.Post("/move", org.MoveIssues)
|
||||
// })
|
||||
// })
|
||||
})
|
||||
}, repoAssignment())
|
||||
|
||||
})
|
||||
|
||||
m.Group("", func() {
|
||||
// Miscellaneous (no scope required)
|
||||
if setting.API.EnableSwagger {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
project_model "code.gitea.io/gitea/models/project"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/context"
|
||||
)
|
||||
|
||||
func CreateProject(ctx *context.APIContext) {
|
||||
form := web.GetForm(ctx).(*api.CreateProjectOption)
|
||||
|
||||
log.Println(ctx.ContextUser.ID)
|
||||
|
||||
project := &project_model.Project{
|
||||
OwnerID: ctx.ContextUser.ID,
|
||||
Title: form.Title,
|
||||
Description: form.Content,
|
||||
CreatorID: ctx.Doer.ID,
|
||||
TemplateType: project_model.TemplateType(form.TemplateType),
|
||||
CardType: project_model.CardType(form.CardType),
|
||||
}
|
||||
|
||||
if ctx.ContextUser.IsOrganization() {
|
||||
project.Type = project_model.TypeOrganization
|
||||
} else {
|
||||
project.Type = project_model.TypeIndividual
|
||||
}
|
||||
|
||||
if err := project_model.NewProject(ctx, project); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "NewProject", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusCreated, map[string]int64{"id": project.ID})
|
||||
}
|
||||
Reference in New Issue
Block a user