1
0
Fork 0
forked from forgejo/forgejo

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>
This commit is contained in:
yp05327 2023-03-17 22:07:23 +09:00 committed by GitHub
parent 8120c0c20c
commit 8e45fcb63a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 7 deletions

View file

@ -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
}