Compare commits

...

14 Commits

129 changed files with 9455 additions and 9019 deletions

View File

@ -27,11 +27,11 @@ import (
ics "github.com/arran4/golang-ical"
)
func GetCaldavTodosForTasks(list *models.ListWithTasksAndBuckets, listTasks []*models.TaskWithComments) string {
func GetCaldavTodosForTasks(project *models.ProjectWithTasksAndBuckets, projectTasks []*models.TaskWithComments) string {
// Make caldav todos from Vikunja todos
var caldavtodos []*Todo
for _, t := range listTasks {
for _, t := range projectTasks {
duration := t.EndDate.Sub(t.StartDate)
@ -55,7 +55,7 @@ func GetCaldavTodosForTasks(list *models.ListWithTasksAndBuckets, listTasks []*m
}
caldavConfig := &Config{
Name: list.Title,
Name: project.Title,
ProdID: "Vikunja Todo App",
}

View File

@ -73,7 +73,7 @@ func init() {
// User deletion flags
userDeleteCmd.Flags().BoolVarP(&userFlagDeleteNow, "now", "n", false, "If provided, deletes the user immediately instead of sending them an email first.")
userCmd.AddCommand(userListCmd, userCreateCmd, userUpdateCmd, userResetPasswordCmd, userChangeEnabledCmd, userDeleteCmd)
userCmd.AddCommand(userProjectCmd, userCreateCmd, userUpdateCmd, userResetPasswordCmd, userChangeEnabledCmd, userDeleteCmd)
rootCmd.AddCommand(userCmd)
}
@ -117,9 +117,9 @@ var userCmd = &cobra.Command{
Short: "Manage users locally through the cli.",
}
var userListCmd = &cobra.Command{
Use: "list",
Short: "Shows a list of all users.",
var userProjectCmd = &cobra.Command{
Use: "project",
Short: "Shows a project of all users.",
PreRun: func(cmd *cobra.Command, args []string) {
initialize.FullInit()
},
@ -127,7 +127,7 @@ var userListCmd = &cobra.Command{
s := db.NewSession()
defer s.Close()
users, err := user.ListAllUsers(s)
users, err := user.ProjectAllUsers(s)
if err != nil {
_ = s.Rollback()
log.Fatalf("Error getting users: %s", err)

View File

@ -164,7 +164,7 @@ const (
DefaultSettingsDiscoverableByName Key = `defaultsettings.discoverable_by_name`
DefaultSettingsDiscoverableByEmail Key = `defaultsettings.discoverable_by_email`
DefaultSettingsOverdueTaskRemindersEnabled Key = `defaultsettings.overdue_tasks_reminders_enabled`
DefaultSettingsDefaultListID Key = `defaultsettings.default_list_id`
DefaultSettingsDefaultProjectID Key = `defaultsettings.default_project_id`
DefaultSettingsWeekStart Key = `defaultsettings.week_start`
DefaultSettingsLanguage Key = `defaultsettings.language`
DefaultSettingsTimezone Key = `defaultsettings.timezone`
@ -370,7 +370,7 @@ func InitDefaultConfig() {
MigrationMicrosoftTodoEnable.setDefault(false)
// Avatar
AvatarGravaterExpiration.setDefault(3600)
// List Backgrounds
// Project Backgrounds
BackgroundsEnabled.setDefault(true)
BackgroundsUploadEnabled.setDefault(true)
BackgroundsUnsplashEnabled.setDefault(false)

View File

@ -1,6 +1,6 @@
- id: 1
title: testbucket1
list_id: 1
project_id: 1
created_by_id: 1
limit: 9999999 # This bucket has a limit we will never exceed in the tests to make sure the logic allows for buckets with limits
position: 1
@ -8,7 +8,7 @@
updated: 2020-04-18 21:13:52
- id: 2
title: testbucket2
list_id: 1
project_id: 1
created_by_id: 1
limit: 3
position: 2
@ -16,15 +16,15 @@
updated: 2020-04-18 21:13:52
- id: 3
title: testbucket3
list_id: 1
project_id: 1
created_by_id: 1
is_done_bucket: 1
position: 3
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 4
title: testbucket4 - other list
list_id: 2
title: testbucket4 - other project
project_id: 2
created_by_id: 1
is_done_bucket: 1
created: 2020-04-18 21:13:52
@ -32,189 +32,189 @@
# The following are not or only partly owned by user 1
- id: 5
title: testbucket5
list_id: 20
project_id: 20
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 6
title: testbucket6
list_id: 6
project_id: 6
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 7
title: testbucket7
list_id: 7
project_id: 7
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 8
title: testbucket8
list_id: 8
project_id: 8
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 9
title: testbucket9
list_id: 9
project_id: 9
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 10
title: testbucket10
list_id: 10
project_id: 10
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 11
title: testbucket11
list_id: 11
project_id: 11
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 12
title: testbucket13
list_id: 12
project_id: 12
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 13
title: testbucket13
list_id: 13
project_id: 13
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 14
title: testbucket14
list_id: 14
project_id: 14
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 15
title: testbucket15
list_id: 15
project_id: 15
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 16
title: testbucket16
list_id: 16
project_id: 16
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 17
title: testbucket17
list_id: 17
project_id: 17
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 18
title: testbucket18
list_id: 5
project_id: 5
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 19
title: testbucket19
list_id: 21
project_id: 21
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 20
title: testbucket20
list_id: 22
project_id: 22
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 21
title: testbucket21
list_id: 3
project_id: 3
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
# Duplicate buckets to make deletion of one of them possible
- id: 22
title: testbucket22
list_id: 6
project_id: 6
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 23
title: testbucket23
list_id: 7
project_id: 7
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 24
title: testbucket24
list_id: 8
project_id: 8
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 25
title: testbucket25
list_id: 9
project_id: 9
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 26
title: testbucket26
list_id: 10
project_id: 10
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 27
title: testbucket27
list_id: 11
project_id: 11
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 28
title: testbucket28
list_id: 12
project_id: 12
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 29
title: testbucket29
list_id: 13
project_id: 13
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 30
title: testbucket30
list_id: 14
project_id: 14
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 31
title: testbucket31
list_id: 15
project_id: 15
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 32
title: testbucket32
list_id: 16
project_id: 16
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 33
title: testbucket33
list_id: 17
project_id: 17
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
# This bucket is the last one in its list
# This bucket is the last one in its project
- id: 34
title: testbucket34
list_id: 18
project_id: 18
created_by_id: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 35
title: testbucket35
list_id: 23
project_id: 23
created_by_id: -2
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52

View File

@ -1,6 +1,6 @@
- id: 1
hash: test
list_id: 1
project_id: 1
right: 0
sharing_type: 1
shared_by_id: 1
@ -8,7 +8,7 @@
updated: 2018-12-02 15:13:12
- id: 2
hash: test2
list_id: 2
project_id: 2
right: 1
sharing_type: 1
shared_by_id: 1
@ -16,7 +16,7 @@
updated: 2018-12-02 15:13:12
- id: 3
hash: test3
list_id: 3
project_id: 3
right: 2
sharing_type: 1
shared_by_id: 1
@ -24,7 +24,7 @@
updated: 2018-12-02 15:13:12
- id: 4
hash: testWithPassword
list_id: 1
project_id: 1
right: 0
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
sharing_type: 2

View File

@ -168,8 +168,8 @@
position: 17
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
# This list is owned by user 7, and several other users have access to it via different methods.
# It is used to test the listUsers method.
# This project is owned by user 7, and several other users have access to it via different methods.
# It is used to test the projectUsers method.
-
id: 18
title: Test18
@ -190,7 +190,7 @@
position: 19
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
# User 1 does not have access to this list
# User 1 does not have access to this project
-
id: 20
title: Test20

View File

@ -9,13 +9,13 @@
user_id: 6
created: 2021-02-01 15:13:12
- id: 3
entity_type: 2 # List
entity_type: 2 # project
entity_id: 12 # belongs to namespace 7
user_id: 6
created: 2021-02-01 15:13:12
- id: 4
entity_type: 3 # Task
entity_id: 22 # belongs to list 13 which belongs to namespace 8
entity_id: 22 # belongs to project 13 which belongs to namespace 8
user_id: 6
created: 2021-02-01 15:13:12
- id: 5
@ -24,7 +24,7 @@
user_id: 6
created: 2021-02-01 15:13:12
- id: 6
entity_type: 2 # List
entity_type: 2 # project
entity_id: 13
user_id: 6
created: 2021-02-01 15:13:12

View File

@ -3,7 +3,7 @@
description: 'Lorem Ipsum'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 1
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -13,7 +13,7 @@
title: 'task #2 done'
done: true
created_by_id: 1
list_id: 1
project_id: 1
index: 2
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -23,7 +23,7 @@
title: 'task #3 high prio'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 3
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -33,7 +33,7 @@
title: 'task #4 low prio'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 4
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -43,7 +43,7 @@
title: 'task #5 higher due date'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 5
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -53,7 +53,7 @@
title: 'task #6 lower due date'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 6
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -63,7 +63,7 @@
title: 'task #7 with start date'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 7
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -73,7 +73,7 @@
title: 'task #8 with end date'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 8
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -83,7 +83,7 @@
title: 'task #9 with start and end date'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 9
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -94,7 +94,7 @@
title: 'task #10 basic'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 10
bucket_id: 1
created: 2018-12-01 01:12:04
@ -103,7 +103,7 @@
title: 'task #11 basic'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 11
bucket_id: 1
created: 2018-12-01 01:12:04
@ -112,25 +112,25 @@
title: 'task #12 basic'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 12
bucket_id: 1
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
- id: 13
title: 'task #13 basic other list'
title: 'task #13 basic other project'
done: false
created_by_id: 1
list_id: 2
project_id: 2
index: 1
bucket_id: 4
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
- id: 14
title: 'task #14 basic other list'
title: 'task #14 basic other project'
done: false
created_by_id: 5
list_id: 5
project_id: 5
index: 1
bucket_id: 18
created: 2018-12-01 01:12:04
@ -139,7 +139,7 @@
title: 'task #15'
done: false
created_by_id: 6
list_id: 6
project_id: 6
index: 1
bucket_id: 6
created: 2018-12-01 01:12:04
@ -148,7 +148,7 @@
title: 'task #16'
done: false
created_by_id: 6
list_id: 7
project_id: 7
index: 1
bucket_id: 7
created: 2018-12-01 01:12:04
@ -157,7 +157,7 @@
title: 'task #17'
done: false
created_by_id: 6
list_id: 8
project_id: 8
index: 1
bucket_id: 8
created: 2018-12-01 01:12:04
@ -166,7 +166,7 @@
title: 'task #18'
done: false
created_by_id: 6
list_id: 9
project_id: 9
index: 1
bucket_id: 9
created: 2018-12-01 01:12:04
@ -175,7 +175,7 @@
title: 'task #19'
done: false
created_by_id: 6
list_id: 10
project_id: 10
index: 1
bucket_id: 10
created: 2018-12-01 01:12:04
@ -184,7 +184,7 @@
title: 'task #20'
done: false
created_by_id: 6
list_id: 11
project_id: 11
index: 1
bucket_id: 11
created: 2018-12-01 01:12:04
@ -193,7 +193,7 @@
title: 'task #21'
done: false
created_by_id: 6
list_id: 12
project_id: 12
index: 1
bucket_id: 12
created: 2018-12-01 01:12:04
@ -202,7 +202,7 @@
title: 'task #22'
done: false
created_by_id: 6
list_id: 13
project_id: 13
index: 1
bucket_id: 13
created: 2018-12-01 01:12:04
@ -211,7 +211,7 @@
title: 'task #23'
done: false
created_by_id: 6
list_id: 14
project_id: 14
index: 1
bucket_id: 14
created: 2018-12-01 01:12:04
@ -220,7 +220,7 @@
title: 'task #24'
done: false
created_by_id: 6
list_id: 15
project_id: 15
index: 1
bucket_id: 15
created: 2018-12-01 01:12:04
@ -229,7 +229,7 @@
title: 'task #25'
done: false
created_by_id: 6
list_id: 16
project_id: 16
index: 1
bucket_id: 16
created: 2018-12-01 01:12:04
@ -238,7 +238,7 @@
title: 'task #26'
done: false
created_by_id: 6
list_id: 17
project_id: 17
index: 1
bucket_id: 17
created: 2018-12-01 01:12:04
@ -247,7 +247,7 @@
title: 'task #27 with reminders'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 12
bucket_id: 1
created: 2018-12-01 01:12:04
@ -257,7 +257,7 @@
done: false
created_by_id: 1
repeat_after: 3600
list_id: 1
project_id: 1
index: 13
bucket_id: 1
created: 2018-12-01 01:12:04
@ -266,7 +266,7 @@
title: 'task #29 with parent task (1)'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 14
bucket_id: 1
created: 2018-12-01 01:12:04
@ -275,7 +275,7 @@
title: 'task #30 with assignees'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 15
bucket_id: 1
created: 2018-12-01 01:12:04
@ -284,7 +284,7 @@
title: 'task #31 with color'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 16
hex_color: f0f0f0
bucket_id: 1
@ -294,7 +294,7 @@
title: 'task #32'
done: false
created_by_id: 1
list_id: 3
project_id: 3
index: 1
bucket_id: 21
created: 2018-12-01 01:12:04
@ -303,7 +303,7 @@
title: 'task #33 with percent done'
done: false
created_by_id: 1
list_id: 1
project_id: 1
index: 17
percent_done: 0.5
bucket_id: 1
@ -314,7 +314,7 @@
title: 'task #34'
done: false
created_by_id: 13
list_id: 20
project_id: 20
index: 20
bucket_id: 5
created: 2018-12-01 01:12:04
@ -323,7 +323,7 @@
title: 'task #35'
done: false
created_by_id: 1
list_id: 21
project_id: 21
index: 1
bucket_id: 19
created: 2018-12-01 01:12:04
@ -332,7 +332,7 @@
title: 'task #36'
done: false
created_by_id: 1
list_id: 22
project_id: 22
index: 1
bucket_id: 20
created: 2018-12-01 01:12:04
@ -342,7 +342,7 @@
title: 'task #37'
done: false
created_by_id: -2
list_id: 2
project_id: 2
index: 2
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04
@ -350,7 +350,7 @@
title: 'task #37 done with due date'
done: true
created_by_id: 1
list_id: 22
project_id: 22
index: 2
created: 2018-12-01 01:12:04
updated: 2018-12-01 01:12:04

View File

@ -1,54 +1,54 @@
- id: 1
team_id: 1
list_id: 3
project_id: 3
right: 0
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
# This team has read only access on list 6
# This team has read only access on project 6
- id: 2
team_id: 2
list_id: 6
project_id: 6
right: 0
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
# This team has write access on list 7
# This team has write access on project 7
- id: 3
team_id: 3
list_id: 7
project_id: 7
right: 1
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
# This team has admin access on list 8
# This team has admin access on project 8
- id: 4
team_id: 4
list_id: 8
project_id: 8
right: 2
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
# Readonly acces on list 19
# Readonly acces on project 19
- id: 5
team_id: 8
list_id: 19
project_id: 19
right: 2
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
# Write acces on list 19
# Write acces on project 19
- id: 6
team_id: 9
list_id: 19
project_id: 19
right: 1
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
# Admin acces on list 19
# Admin acces on project 19
- id: 7
team_id: 10
list_id: 19
project_id: 19
right: 2
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 8
team_id: 1
list_id: 21
project_id: 21
right: 0
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12

View File

@ -3,13 +3,13 @@
description: Lorem Ipsum
created_by_id: 1
- id: 2
name: testteam2_read_only_on_list6
name: testteam2_read_only_on_project6
created_by_id: 1
- id: 3
name: testteam3_write_on_list7
name: testteam3_write_on_project7
created_by_id: 1
- id: 4
name: testteam4_admin_on_list8
name: testteam4_admin_on_project8
created_by_id: 1
- id: 5
name: testteam2_read_only_on_namespace7

View File

@ -40,7 +40,7 @@
issuer: local
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
# This use is used to create a whole bunch of lists which are then shared directly with a user
# This use is used to create a whole bunch of projects which are then shared directly with a user
- id: 6
username: 'user6'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234

View File

@ -1,48 +1,48 @@
- id: 1
user_id: 1
list_id: 3
project_id: 3
right: 0
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 2
user_id: 2
list_id: 3
project_id: 3
right: 0
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 3
user_id: 1
list_id: 9
project_id: 9
right: 0
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 4
user_id: 1
list_id: 10
project_id: 10
right: 1
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 5
user_id: 1
list_id: 11
project_id: 11
right: 2
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 6
user_id: 4
list_id: 19
project_id: 19
right: 0
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 7
user_id: 5
list_id: 19
project_id: 19
right: 1
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 8
user_id: 6
list_id: 19
project_id: 19
right: 2
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12

View File

@ -28,37 +28,37 @@ import (
// This tests the following behaviour:
// 1. A namespace should not be editable if it is archived.
// 1. With the exception being to un-archive it.
// 2. A list which belongs to an archived namespace cannot be edited.
// 3. An archived list should not be editable.
// 2. A project which belongs to an archived namespace cannot be edited.
// 3. An archived project should not be editable.
// 1. Except for un-archiving it.
// 4. It is not possible to un-archive a list individually if its namespace is archived.
// 5. Creating new lists on an archived namespace should not work.
// 6. Creating new tasks on an archived list should not work.
// 7. Creating new tasks on a list who's namespace is archived should not work.
// 8. Editing tasks on an archived list should not work.
// 9. Editing tasks on a list who's namespace is archived should not work.
// 10. Archived namespaces should not appear in the list with all namespaces.
// 11. Archived lists should not appear in the list with all lists.
// 12. Lists who's namespace is archived should not appear in the list with all lists.
// 4. It is not possible to un-archive a project individually if its namespace is archived.
// 5. Creating new projects on an archived namespace should not work.
// 6. Creating new tasks on an archived project should not work.
// 7. Creating new tasks on a project who's namespace is archived should not work.
// 8. Editing tasks on an archived project should not work.
// 9. Editing tasks on a project who's namespace is archived should not work.
// 10. Archived namespaces should not appear in the project with all namespaces.
// 11. Archived projects should not appear in the project with all projects.
// 12. Projects who's namespace is archived should not appear in the project with all projects.
//
// All of this is tested through integration tests because it's not yet clear if this will be implemented directly
// or with some kind of middleware.
//
// Maybe the inheritance of lists from namespaces could be solved with some kind of is_archived_inherited flag -
// that way I'd only need to implement the checking on a list level and update the flag for all lists once the
// namespace is archived. The archived flag would then be used to not accedentially unarchive lists which were
// Maybe the inheritance of projects from namespaces could be solved with some kind of is_archived_inherited flag -
// that way I'd only need to implement the checking on a project level and update the flag for all projects once the
// namespace is archived. The archived flag would then be used to not accedentially unarchive projects which were
// already individually archived when the namespace was archived.
// Should still test it all though.
//
// Namespace 16 is archived
// List 21 belongs to namespace 16
// List 22 is archived individually
// Project 21 belongs to namespace 16
// Project 22 is archived individually
func TestArchived(t *testing.T) {
testListHandler := webHandlerTest{
testProjectHandler := webHandlerTest{
user: &testuser1,
strFunc: func() handler.CObject {
return &models.List{}
return &models.Project{}
},
t: t,
}
@ -116,54 +116,54 @@ func TestArchived(t *testing.T) {
assert.NoError(t, err)
assert.Contains(t, rec.Body.String(), `"is_archived":false`)
})
t.Run("no new lists", func(t *testing.T) {
_, err := testListHandler.testCreateWithUser(nil, map[string]string{"namespace": "16"}, `{"title":"Lorem"}`)
t.Run("no new projects", func(t *testing.T) {
_, err := testProjectHandler.testCreateWithUser(nil, map[string]string{"namespace": "16"}, `{"title":"Lorem"}`)
assert.Error(t, err)
assertHandlerErrorCode(t, err, models.ErrCodeNamespaceIsArchived)
})
t.Run("should not appear in the list", func(t *testing.T) {
t.Run("should not appear in the project", func(t *testing.T) {
rec, err := testNamespaceHandler.testReadAllWithUser(nil, nil)
assert.NoError(t, err)
assert.NotContains(t, rec.Body.String(), `"title":"Archived testnamespace16"`)
})
t.Run("should appear in the list if explicitly requested", func(t *testing.T) {
t.Run("should appear in the project if explicitly requested", func(t *testing.T) {
rec, err := testNamespaceHandler.testReadAllWithUser(url.Values{"is_archived": []string{"true"}}, nil)
assert.NoError(t, err)
assert.Contains(t, rec.Body.String(), `"title":"Archived testnamespace16"`)
})
})
t.Run("list", func(t *testing.T) {
t.Run("project", func(t *testing.T) {
taskTests := func(taskID string, errCode int, t *testing.T) {
t.Run("task", func(t *testing.T) {
t.Run("edit task", func(t *testing.T) {
_, err := testTaskHandler.testUpdateWithUser(nil, map[string]string{"listtask": taskID}, `{"title":"TestIpsum"}`)
_, err := testTaskHandler.testUpdateWithUser(nil, map[string]string{"projecttask": taskID}, `{"title":"TestIpsum"}`)
assert.Error(t, err)
assertHandlerErrorCode(t, err, errCode)
})
t.Run("delete", func(t *testing.T) {
_, err := testTaskHandler.testDeleteWithUser(nil, map[string]string{"listtask": taskID})
_, err := testTaskHandler.testDeleteWithUser(nil, map[string]string{"projecttask": taskID})
assert.Error(t, err)
assertHandlerErrorCode(t, err, errCode)
})
t.Run("add new labels", func(t *testing.T) {
_, err := testLabelHandler.testCreateWithUser(nil, map[string]string{"listtask": taskID}, `{"label_id":1}`)
_, err := testLabelHandler.testCreateWithUser(nil, map[string]string{"projecttask": taskID}, `{"label_id":1}`)
assert.Error(t, err)
assertHandlerErrorCode(t, err, errCode)
})
t.Run("remove lables", func(t *testing.T) {
_, err := testLabelHandler.testDeleteWithUser(nil, map[string]string{"listtask": taskID, "label": "4"})
_, err := testLabelHandler.testDeleteWithUser(nil, map[string]string{"projecttask": taskID, "label": "4"})
assert.Error(t, err)
assertHandlerErrorCode(t, err, errCode)
})
t.Run("add assignees", func(t *testing.T) {
_, err := testAssigneeHandler.testCreateWithUser(nil, map[string]string{"listtask": taskID}, `{"user_id":3}`)
_, err := testAssigneeHandler.testCreateWithUser(nil, map[string]string{"projecttask": taskID}, `{"user_id":3}`)
assert.Error(t, err)
assertHandlerErrorCode(t, err, errCode)
})
t.Run("remove assignees", func(t *testing.T) {
_, err := testAssigneeHandler.testDeleteWithUser(nil, map[string]string{"listtask": taskID, "user": "2"})
_, err := testAssigneeHandler.testDeleteWithUser(nil, map[string]string{"projecttask": taskID, "user": "2"})
assert.Error(t, err)
assertHandlerErrorCode(t, err, errCode)
})
@ -194,45 +194,45 @@ func TestArchived(t *testing.T) {
})
}
// The list belongs to an archived namespace
// The project belongs to an archived namespace
t.Run("archived namespace", func(t *testing.T) {
t.Run("not editable", func(t *testing.T) {
_, err := testListHandler.testUpdateWithUser(nil, map[string]string{"list": "21"}, `{"title":"TestIpsum","is_archived":true}`)
_, err := testProjectHandler.testUpdateWithUser(nil, map[string]string{"project": "21"}, `{"title":"TestIpsum","is_archived":true}`)
assert.Error(t, err)
assertHandlerErrorCode(t, err, models.ErrCodeNamespaceIsArchived)
})
t.Run("no new tasks", func(t *testing.T) {
_, err := testTaskHandler.testCreateWithUser(nil, map[string]string{"list": "21"}, `{"title":"Lorem"}`)
_, err := testTaskHandler.testCreateWithUser(nil, map[string]string{"project": "21"}, `{"title":"Lorem"}`)
assert.Error(t, err)
assertHandlerErrorCode(t, err, models.ErrCodeNamespaceIsArchived)
})
t.Run("not unarchivable", func(t *testing.T) {
_, err := testListHandler.testUpdateWithUser(nil, map[string]string{"list": "21"}, `{"title":"LoremIpsum","is_archived":false}`)
_, err := testProjectHandler.testUpdateWithUser(nil, map[string]string{"project": "21"}, `{"title":"LoremIpsum","is_archived":false}`)
assert.Error(t, err)
assertHandlerErrorCode(t, err, models.ErrCodeNamespaceIsArchived)
})
taskTests("35", models.ErrCodeNamespaceIsArchived, t)
})
// The list itself is archived
// The project itself is archived
t.Run("archived individually", func(t *testing.T) {
t.Run("not editable", func(t *testing.T) {
_, err := testListHandler.testUpdateWithUser(nil, map[string]string{"list": "22"}, `{"title":"TestIpsum","is_archived":true}`)
_, err := testProjectHandler.testUpdateWithUser(nil, map[string]string{"project": "22"}, `{"title":"TestIpsum","is_archived":true}`)
assert.Error(t, err)
assertHandlerErrorCode(t, err, models.ErrCodeListIsArchived)
assertHandlerErrorCode(t, err, models.ErrCodeProjectIsArchived)
})
t.Run("no new tasks", func(t *testing.T) {
_, err := testTaskHandler.testCreateWithUser(nil, map[string]string{"list": "22"}, `{"title":"Lorem"}`)
_, err := testTaskHandler.testCreateWithUser(nil, map[string]string{"project": "22"}, `{"title":"Lorem"}`)
assert.Error(t, err)
assertHandlerErrorCode(t, err, models.ErrCodeListIsArchived)
assertHandlerErrorCode(t, err, models.ErrCodeProjectIsArchived)
})
t.Run("unarchivable", func(t *testing.T) {
rec, err := testListHandler.testUpdateWithUser(nil, map[string]string{"list": "22"}, `{"title":"LoremIpsum","is_archived":false,"namespace_id":1}`)
rec, err := testProjectHandler.testUpdateWithUser(nil, map[string]string{"project": "22"}, `{"title":"LoremIpsum","is_archived":false,"namespace_id":1}`)
assert.NoError(t, err)
assert.Contains(t, rec.Body.String(), `"is_archived":false`)
})
taskTests("36", models.ErrCodeListIsArchived, t)
taskTests("36", models.ErrCodeProjectIsArchived, t)
})
})
}

View File

@ -39,7 +39,7 @@ func TestBucket(t *testing.T) {
linkShare: &models.LinkSharing{
ID: 2,
Hash: "test2",
ListID: 2,
ProjectID: 2,
Right: models.RightWrite,
SharingType: models.SharingTypeWithoutPassword,
SharedByID: 1,
@ -51,17 +51,17 @@ func TestBucket(t *testing.T) {
}
t.Run("ReadAll", func(t *testing.T) {
t.Run("Normal", func(t *testing.T) {
rec, err := testHandler.testReadAllWithUser(nil, map[string]string{"list": "1"})
rec, err := testHandler.testReadAllWithUser(nil, map[string]string{"project": "1"})
assert.NoError(t, err)
assert.Contains(t, rec.Body.String(), `testbucket1`)
assert.Contains(t, rec.Body.String(), `testbucket2`)
assert.Contains(t, rec.Body.String(), `testbucket3`)
assert.NotContains(t, rec.Body.String(), `testbucket4`) // Different List
assert.NotContains(t, rec.Body.String(), `testbucket4`) // Different Project
})
})
t.Run("Update", func(t *testing.T) {
t.Run("Normal", func(t *testing.T) {
// Check the list was loaded successfully afterwards, see testReadOneWithUser
// Check the project was loaded successfully afterwards, see testReadOneWithUser
rec, err := testHandler.testUpdateWithUser(nil, map[string]string{"bucket": "1"}, `{"title":"TestLoremIpsum"}`)
assert.NoError(t, err)
assert.Contains(t, rec.Body.String(), `"title":"TestLoremIpsum"`)
@ -150,7 +150,7 @@ func TestBucket(t *testing.T) {
})
t.Run("Delete", func(t *testing.T) {
t.Run("Normal", func(t *testing.T) {