diff options
author | yp05327 <576951401@qq.com> | 2023-03-17 22:07:23 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-17 21:07:23 +0800 |
commit | 8e45fcb63aeedcf89a705227fa7675698d68d43c (patch) | |
tree | 8facfd85193ff8907673e3e1d1f8e33e27a4c44e /routers/web/org | |
parent | 8120c0c20c42f46d08356064c7f7fe96fafcfade (diff) | |
download | gitea-8e45fcb63aeedcf89a705227fa7675698d68d43c.tar.gz gitea-8e45fcb63aeedcf89a705227fa7675698d68d43c.zip |
Do not store user projects as organization projects (#23353)
A part of https://github.com/go-gitea/gitea/pull/22865
At first, I think we do not need 3 ProjectTypes, as we can check user
type, but it seems that it is not database friendly.
---------
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers/web/org')
-rw-r--r-- | routers/web/org/projects.go | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go index c9d63fec5d..df16d0a4c7 100644 --- a/routers/web/org/projects.go +++ b/routers/web/org/projects.go @@ -51,12 +51,18 @@ func Projects(ctx *context.Context) { page = 1 } + var projectType project_model.Type + if ctx.ContextUser.IsOrganization() { + projectType = project_model.TypeOrganization + } else { + projectType = project_model.TypeIndividual + } projects, total, err := project_model.FindProjects(ctx, project_model.SearchOptions{ OwnerID: ctx.ContextUser.ID, Page: page, IsClosed: util.OptionalBoolOf(isShowClosed), SortType: sortType, - Type: project_model.TypeOrganization, + Type: projectType, }) if err != nil { ctx.ServerError("FindProjects", err) @@ -66,7 +72,7 @@ func Projects(ctx *context.Context) { opTotal, err := project_model.CountProjects(ctx, project_model.SearchOptions{ OwnerID: ctx.ContextUser.ID, IsClosed: util.OptionalBoolOf(!isShowClosed), - Type: project_model.TypeOrganization, + Type: projectType, }) if err != nil { ctx.ServerError("CountProjects", err) @@ -143,14 +149,21 @@ func NewProjectPost(ctx *context.Context) { return } - if err := project_model.NewProject(&project_model.Project{ + newProject := project_model.Project{ OwnerID: ctx.ContextUser.ID, Title: form.Title, Description: form.Content, CreatorID: ctx.Doer.ID, BoardType: form.BoardType, - Type: project_model.TypeOrganization, - }); err != nil { + } + + if ctx.ContextUser.IsOrganization() { + newProject.Type = project_model.TypeOrganization + } else { + newProject.Type = project_model.TypeIndividual + } + + if err := project_model.NewProject(&newProject); err != nil { ctx.ServerError("NewProject", err) return } |