feat: remove namespaces, make projects infinitely nestable #1362

Merged
konrad merged 68 commits from feature/namespaces-be-gone into main 2023-05-24 14:14:03 +00:00
1 changed files with 1 additions and 23 deletions
Showing only changes of commit ac0d84a7d8 - Show all commits

View File

@ -30,7 +30,7 @@ import (
)
// InsertFromStructure takes a fully nested Vikunja data structure and a user and then creates everything for this user
// (Namespaces, tasks, etc. Even attachments and relations.)
// (Projects, tasks, etc. Even attachments and relations.)
func InsertFromStructure(str []*models.ProjectWithTasksAndBuckets, user *user.User) (err error) {
s := db.NewSession()
defer s.Close()
@ -52,28 +52,16 @@ func insertFromStructure(s *xorm.Session, str []*models.ProjectWithTasksAndBucke
labels := make(map[string]*models.Label)
archivedProjects := []int64{}
archivedNamespaces := []int64{}
// Create all namespaces
for _, p := range str {
p.ID = 0
// Saving the archived status to archive the namespace again after creating it
var wasArchived bool
if p.IsArchived {
p.IsArchived = false
wasArchived = true
}
err = p.Create(s, user)
if err != nil {
return
}
if wasArchived {
archivedNamespaces = append(archivedNamespaces, p.ID)
}
log.Debugf("[creating structure] Created project %d", p.ID)
log.Debugf("[creating structure] Creating %d projects", len(p.ChildProjects))
@ -290,16 +278,6 @@ func insertFromStructure(s *xorm.Session, str []*models.ProjectWithTasksAndBucke
}
}
if len(archivedNamespaces) > 0 {
_, err = s.
Cols("is_archived").
In("id", archivedNamespaces).
Update(&models.Project{IsArchived: true})
if err != nil {
return err
}
}
log.Debugf("[creating structure] Done inserting new task structure")
return nil