aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/projects.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-01-20 19:42:33 +0800
committerGitHub <noreply@github.com>2023-01-20 19:42:33 +0800
commit6fe3c8b3980f850c9789f9fa62bdfee7b2708ff0 (patch)
tree5e11864dd63c60564080506291ca93e465c19940 /routers/web/repo/projects.go
parent0c048e554ba42d99bd66c07447de5f35cf6c981b (diff)
downloadgitea-6fe3c8b3980f850c9789f9fa62bdfee7b2708ff0.tar.gz
gitea-6fe3c8b3980f850c9789f9fa62bdfee7b2708ff0.zip
Support org/user level projects (#22235)
Fix #13405 <img width="1151" alt="image" src="https://user-images.githubusercontent.com/81045/209442911-7baa3924-c389-47b6-b63b-a740803e640e.png"> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers/web/repo/projects.go')
-rw-r--r--routers/web/repo/projects.go48
1 files changed, 2 insertions, 46 deletions
diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go
index 75cd290b8f..3becf799c5 100644
--- a/routers/web/repo/projects.go
+++ b/routers/web/repo/projects.go
@@ -70,7 +70,7 @@ func Projects(ctx *context.Context) {
total = repo.NumClosedProjects
}
- projects, count, err := project_model.GetProjects(ctx, project_model.SearchOptions{
+ projects, count, err := project_model.FindProjects(ctx, project_model.SearchOptions{
RepoID: repo.ID,
Page: page,
IsClosed: util.OptionalBoolOf(isShowClosed),
@@ -112,7 +112,7 @@ func Projects(ctx *context.Context) {
pager.AddParam(ctx, "state", "State")
ctx.Data["Page"] = pager
- ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
+ ctx.Data["CanWriteProjects"] = true
ctx.Data["IsShowClosed"] = isShowClosed
ctx.Data["IsProjectsPage"] = true
ctx.Data["SortType"] = sortType
@@ -653,47 +653,3 @@ func MoveIssues(ctx *context.Context) {
"ok": true,
})
}
-
-// CreateProject renders the generic project creation page
-func CreateProject(ctx *context.Context) {
- ctx.Data["Title"] = ctx.Tr("repo.projects.new")
- ctx.Data["ProjectTypes"] = project_model.GetProjectsConfig()
- ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
-
- ctx.HTML(http.StatusOK, tplGenericProjectsNew)
-}
-
-// CreateProjectPost creates an individual and/or organization project
-func CreateProjectPost(ctx *context.Context, form forms.UserCreateProjectForm) {
- user := checkContextUser(ctx, form.UID)
- if ctx.Written() {
- return
- }
-
- ctx.Data["ContextUser"] = user
-
- if ctx.HasError() {
- ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
- ctx.HTML(http.StatusOK, tplGenericProjectsNew)
- return
- }
-
- projectType := project_model.TypeIndividual
- if user.IsOrganization() {
- projectType = project_model.TypeOrganization
- }
-
- if err := project_model.NewProject(&project_model.Project{
- Title: form.Title,
- Description: form.Content,
- CreatorID: user.ID,
- BoardType: form.BoardType,
- Type: projectType,
- }); err != nil {
- ctx.ServerError("NewProject", err)
- return
- }
-
- ctx.Flash.Success(ctx.Tr("repo.projects.create_success", form.Title))
- ctx.Redirect(setting.AppSubURL + "/")
-}