From 17898f7a1c4faaacd2622cb9b8d32af1502025f6 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 29 Dec 2022 21:06:29 +0100 Subject: [PATCH] feat(projects): check parent project when checking archived status --- pkg/models/prject.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/models/prject.go b/pkg/models/prject.go index 266375387..fee137000 100644 --- a/pkg/models/prject.go +++ b/pkg/models/prject.go @@ -592,8 +592,7 @@ func addProjectDetails(s *xorm.Session, projects map[int64]*Project, a web.Auth) // CheckIsArchived returns an ErrProjectIsArchived if the project or any of its parent projects is archived. func (p *Project) CheckIsArchived(s *xorm.Session) (err error) { - // When creating a new project, we check if the parent is archived - if p.ID == 0 { + if p.ParentProjectID > 0 { p := &Project{ID: p.ParentProjectID} return p.CheckIsArchived(s) } @@ -603,8 +602,6 @@ func (p *Project) CheckIsArchived(s *xorm.Session) (err error) { return err } - // TODO: parent project - if project.IsArchived { return ErrProjectIsArchived{ProjectID: p.ID} } @@ -655,7 +652,6 @@ func CreateProject(s *xorm.Session, project *Project, auth web.Auth) (err error) project.OwnerID = doer.ID project.Owner = doer - project.ID = 0 // Otherwise only the first time a new project would be created err = checkProjectBeforeUpdateOrDelete(s, project) if err != nil {