fix(project): duplicating a project should not create two backlog buckets
Resolves https://community.vikunja.io/t/when-duplicating-a-project-the-resulting-project-has-an-extra-bucket/1524
This commit is contained in:
@ -680,7 +680,7 @@ func checkProjectBeforeUpdateOrDelete(s *xorm.Session, project *Project) (err er
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateProject(s *xorm.Session, project *Project, auth web.Auth) (err error) {
|
||||
func CreateProject(s *xorm.Session, project *Project, auth web.Auth, createBacklogBucket bool) (err error) {
|
||||
err = project.CheckIsArchived(s)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -715,14 +715,16 @@ func CreateProject(s *xorm.Session, project *Project, auth web.Auth) (err error)
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new first bucket for this project
|
||||
b := &Bucket{
|
||||
ProjectID: project.ID,
|
||||
Title: "Backlog",
|
||||
}
|
||||
err = b.Create(s, auth)
|
||||
if err != nil {
|
||||
return
|
||||
if createBacklogBucket {
|
||||
// Create a new first bucket for this project
|
||||
b := &Bucket{
|
||||
ProjectID: project.ID,
|
||||
Title: "Backlog",
|
||||
}
|
||||
err = b.Create(s, auth)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return events.Dispatch(&ProjectCreatedEvent{
|
||||
@ -928,7 +930,7 @@ func updateProjectByTaskID(s *xorm.Session, taskID int64) (err error) {
|
||||
// @Failure 500 {object} models.Message "Internal error"
|
||||
// @Router /projects [put]
|
||||
func (p *Project) Create(s *xorm.Session, a web.Auth) (err error) {
|
||||
err = CreateProject(s, p, a)
|
||||
err = CreateProject(s, p, a, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user