diff --git a/pkg/migration/20220611191202.go b/pkg/migration/20220611191202.go new file mode 100644 index 00000000000..c26fa008ca6 --- /dev/null +++ b/pkg/migration/20220611191202.go @@ -0,0 +1,43 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-2021 Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + +package migration + +import ( + "src.techknowlogick.com/xormigrate" + "xorm.io/xorm" +) + +type users20220611191202 struct { + HomeListID int64 `xorm:"bigint null index" json:"-"` +} + +func (users20220611191202) TableName() string { + return "users" +} + +func init() { + migrations = append(migrations, &xormigrate.Migration{ + ID: "20220611191202", + Description: "Add home list for new tasks setting to users", + Migrate: func(tx *xorm.Engine) error { + return tx.Sync2(users20220611191202{}) + }, + Rollback: func(tx *xorm.Engine) error { + return nil + }, + }) +} diff --git a/pkg/routes/api/v1/user_settings.go b/pkg/routes/api/v1/user_settings.go index 157160aad7c..91bf742b04b 100644 --- a/pkg/routes/api/v1/user_settings.go +++ b/pkg/routes/api/v1/user_settings.go @@ -49,6 +49,7 @@ type UserSettings struct { // If a task is created without a specified list this value should be used. Applies // to tasks made directly in API and from clients. DefaultListID int64 `json:"default_list_id"` + HomeListID int64 `json:"home_list_id"` // The day when the week starts for this user. 0 = sunday, 1 = monday, etc. WeekStart int `json:"week_start"` // The user's language @@ -181,6 +182,7 @@ func UpdateGeneralUserSettings(c echo.Context) error { user.DiscoverableByName = us.DiscoverableByName user.OverdueTasksRemindersEnabled = us.OverdueTasksRemindersEnabled user.DefaultListID = us.DefaultListID + user.HomeListID = us.HomeListID user.WeekStart = us.WeekStart user.Language = us.Language user.Timezone = us.Timezone diff --git a/pkg/routes/api/v1/user_show.go b/pkg/routes/api/v1/user_show.go index 9bcdb348a83..57e4e0aa398 100644 --- a/pkg/routes/api/v1/user_show.go +++ b/pkg/routes/api/v1/user_show.go @@ -72,6 +72,7 @@ func UserShow(c echo.Context) error { DiscoverableByEmail: u.DiscoverableByEmail, OverdueTasksRemindersEnabled: u.OverdueTasksRemindersEnabled, DefaultListID: u.DefaultListID, + HomeListID: u.HomeListID, WeekStart: u.WeekStart, Language: u.Language, Timezone: u.Timezone, diff --git a/pkg/swagger/docs.go b/pkg/swagger/docs.go index 1fbf19e5289..b720782c729 100644 --- a/pkg/swagger/docs.go +++ b/pkg/swagger/docs.go @@ -9160,6 +9160,10 @@ const docTemplate = `{ "description": "If a task is created without a specified list this value should be used. Applies\nto tasks made directly in API and from clients.", "type": "integer" }, + "home_list_id": { + "description": "Used by frontend. The User List that the Users wants to be displayed inside the Home View", + "type": "integer" + }, "discoverable_by_email": { "description": "If true, the user can be found when searching for their exact email.", "type": "boolean" diff --git a/pkg/swagger/swagger.json b/pkg/swagger/swagger.json index a2562926127..4cc299a3c31 100644 --- a/pkg/swagger/swagger.json +++ b/pkg/swagger/swagger.json @@ -9151,6 +9151,10 @@ "description": "If a task is created without a specified list this value should be used. Applies\nto tasks made directly in API and from clients.", "type": "integer" }, + "home_list_id": { + "description": "Used by frontend. The User List that the Users wants to be displayed inside the Home View", + "type": "integer" + }, "discoverable_by_email": { "description": "If true, the user can be found when searching for their exact email.", "type": "boolean" diff --git a/pkg/swagger/swagger.yaml b/pkg/swagger/swagger.yaml index 46d3f79937e..7e0086e210e 100644 --- a/pkg/swagger/swagger.yaml +++ b/pkg/swagger/swagger.yaml @@ -1285,6 +1285,10 @@ definitions: v1.UserSettings: properties: default_list_id: + description: |- + Used by frontend. The User List that the Users wants to be displayed inside the Home View + type: integer + home_list_id: description: |- If a task is created without a specified list this value should be used. Applies to tasks made directly in API and from clients. diff --git a/pkg/user/user.go b/pkg/user/user.go index 7be296e9acf..132c17733bc 100644 --- a/pkg/user/user.go +++ b/pkg/user/user.go @@ -95,6 +95,7 @@ type User struct { DiscoverableByEmail bool `xorm:"bool default false index" json:"-"` OverdueTasksRemindersEnabled bool `xorm:"bool default true index" json:"-"` DefaultListID int64 `xorm:"bigint null index" json:"-"` + HomeListID int64 `xorm:"bigint null index" json:"-"` WeekStart int `xorm:"null" json:"-"` Language string `xorm:"varchar(50) null" json:"-"` Timezone string `xorm:"varchar(255) null" json:"-"` @@ -490,6 +491,7 @@ func UpdateUser(s *xorm.Session, user *User) (updatedUser *User, err error) { "discoverable_by_email", "overdue_tasks_reminders_enabled", "default_list_id", + "home_list_id", "week_start", "language", "timezone",