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
2 changed files with 9 additions and 6 deletions
Showing only changes of commit d79c393e5b - Show all commits

View File

@ -24,8 +24,7 @@ import (
// TaskCollection is a struct used to hold filter details and not clutter the Task struct with information not related to actual tasks. // TaskCollection is a struct used to hold filter details and not clutter the Task struct with information not related to actual tasks.
type TaskCollection struct { type TaskCollection struct {
ProjectID int64 `param:"project" json:"-"` ProjectID int64 `param:"project" json:"-"`
Projects []*Project `json:"-"`
// The query parameter to sort by. This is for ex. done, priority, etc. // The query parameter to sort by. This is for ex. done, priority, etc.
SortBy []string `query:"sort_by" json:"sort_by"` SortBy []string `query:"sort_by" json:"sort_by"`
@ -181,8 +180,9 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
// If the project ID is not set, we get all tasks for the user. // If the project ID is not set, we get all tasks for the user.
// This allows to use this function in Task.ReadAll with a possibility to deprecate the latter at some point. // This allows to use this function in Task.ReadAll with a possibility to deprecate the latter at some point.
var projects []*Project
if tf.ProjectID == 0 { if tf.ProjectID == 0 {
tf.Projects, _, _, err = getRawProjectsForUser( projectMap, _, _, err := getRawProjectsForUser(
s, s,
&projectOptions{ &projectOptions{
user: &user.User{ID: a.GetID()}, user: &user.User{ID: a.GetID()},
@ -192,6 +192,9 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
if err != nil { if err != nil {
return nil, 0, 0, err return nil, 0, 0, err
} }
for _, project := range projectMap {
projects = append(projects, project)
}
} else { } else {
// Check the project exists and the user has acess on it // Check the project exists and the user has acess on it
project := &Project{ID: tf.ProjectID} project := &Project{ID: tf.ProjectID}
@ -202,8 +205,8 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
if !canRead { if !canRead {
return nil, 0, 0, ErrUserDoesNotHaveAccessToProject{ProjectID: tf.ProjectID} return nil, 0, 0, ErrUserDoesNotHaveAccessToProject{ProjectID: tf.ProjectID}
} }
tf.Projects = []*Project{{ID: tf.ProjectID}} projects = []*Project{{ID: tf.ProjectID}}
} }
return getTasksForProjects(s, tf.Projects, a, taskopts) return getTasksForProjects(s, projects, a, taskopts)
} }

View File

@ -47,7 +47,7 @@ func UserProject(c echo.Context) error {
s := db.NewSession() s := db.NewSession()
defer s.Close() defer s.Close()
users, err := user.ProjectUsers(s, search, nil) users, err := user.ListUsers(s, search, nil)
if err != nil { if err != nil {
_ = s.Rollback() _ = s.Rollback()
return handler.HandleHTTPError(err, c) return handler.HandleHTTPError(err, c)