This commit is contained in:
parent
e23014dbe4
commit
51f9d8f690
43
pkg/migration/20210527105701.go
Normal file
43
pkg/migration/20210527105701.go
Normal file
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
package migration
|
||||
|
||||
import (
|
||||
"src.techknowlogick.com/xormigrate"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
type users20210527105701 struct {
|
||||
DefaultListForNewTasks int `xorm:"int default 1 index" json:"-"`
|
||||
}
|
||||
|
||||
func (users20210527105701) TableName() string {
|
||||
return "users"
|
||||
}
|
||||
|
||||
func init() {
|
||||
migrations = append(migrations, &xormigrate.Migration{
|
||||
ID: "20210527105701",
|
||||
Description: "Add default list for new tasks setting to users",
|
||||
Migrate: func(tx *xorm.Engine) error {
|
||||
return tx.Sync2(users20210527105701{})
|
||||
},
|
||||
Rollback: func(tx *xorm.Engine) error {
|
||||
return nil
|
||||
},
|
||||
})
|
||||
}
|
@ -75,6 +75,7 @@ func TestLabelTask_ReadAll(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
},
|
||||
|
@ -55,6 +55,7 @@ func TestLabel_ReadAll(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -105,6 +106,7 @@ func TestLabel_ReadAll(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
},
|
||||
@ -170,6 +172,7 @@ func TestLabel_ReadOne(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -231,6 +234,7 @@ func TestLabel_ReadOne(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
},
|
||||
|
@ -184,6 +184,7 @@ func TestListUser_ReadAll(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
},
|
||||
@ -197,6 +198,7 @@ func TestListUser_ReadAll(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
},
|
||||
|
@ -183,6 +183,7 @@ func TestNamespaceUser_ReadAll(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
},
|
||||
@ -196,6 +197,7 @@ func TestNamespaceUser_ReadAll(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
},
|
||||
|
@ -38,6 +38,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -48,6 +49,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -59,6 +61,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
IsActive: true,
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -43,6 +44,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -54,6 +56,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -66,6 +69,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -78,6 +82,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -89,6 +94,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -101,6 +107,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
EmailRemindersEnabled: true,
|
||||
DiscoverableByEmail: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -112,6 +119,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -123,6 +131,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -134,6 +143,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -146,6 +156,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -159,6 +170,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
EmailRemindersEnabled: true,
|
||||
DiscoverableByName: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
@ -170,6 +182,7 @@ func TestListUsersFromList(t *testing.T) {
|
||||
Issuer: "local",
|
||||
EmailRemindersEnabled: true,
|
||||
OverdueTasksRemindersEnabled: true,
|
||||
DefaultListForNewTasks: 1,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
|
@ -45,6 +45,9 @@ type UserSettings struct {
|
||||
DiscoverableByEmail bool `json:"discoverable_by_email"`
|
||||
// If enabled, the user will get an email for their overdue tasks each morning.
|
||||
OverdueTasksRemindersEnabled bool `json:"overdue_tasks_reminders_enabled"`
|
||||
// If a task is created without a specified list this value should be used. Applies
|
||||
// to tasks made directly in API and from clients.
|
||||
DefaultListForNewTasks int `json:"default_list_for_new_tasks"`
|
||||
}
|
||||
|
||||
// GetUserAvatarProvider returns the currently set user avatar
|
||||
@ -170,6 +173,7 @@ func UpdateGeneralUserSettings(c echo.Context) error {
|
||||
user.DiscoverableByEmail = us.DiscoverableByEmail
|
||||
user.DiscoverableByName = us.DiscoverableByName
|
||||
user.OverdueTasksRemindersEnabled = us.OverdueTasksRemindersEnabled
|
||||
user.DefaultListForNewTasks = us.DefaultListForNewTasks
|
||||
|
||||
_, err = user2.UpdateUser(s, user)
|
||||
if err != nil {
|
||||
|
@ -68,6 +68,7 @@ func UserShow(c echo.Context) error {
|
||||
DiscoverableByName: u.DiscoverableByName,
|
||||
DiscoverableByEmail: u.DiscoverableByEmail,
|
||||
OverdueTasksRemindersEnabled: u.OverdueTasksRemindersEnabled,
|
||||
DefaultListForNewTasks: u.DefaultListForNewTasks,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -8575,6 +8575,10 @@ var doc = `{
|
||||
"overdue_tasks_reminders_enabled": {
|
||||
"description": "If enabled, the user will get an email for their overdue tasks each morning.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_list_for_new_tasks": {
|
||||
"description": "If set this will be the default list used when a task is created with no specified list.",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -8558,6 +8558,10 @@
|
||||
"overdue_tasks_reminders_enabled": {
|
||||
"description": "If enabled, the user will get an email for their overdue tasks each morning.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_list_for_new_tasks": {
|
||||
"description": "If set this will be the default list used when a task is created with no specified list.",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1196,6 +1196,9 @@ definitions:
|
||||
description: If enabled, the user will get an email for their overdue tasks
|
||||
each morning.
|
||||
type: boolean
|
||||
default_list_for_new_tasks:
|
||||
description: If set this will be the default list used when a task is created with no specified list.
|
||||
type: integer
|
||||
type: object
|
||||
v1.authInfo:
|
||||
properties:
|
||||
|
@ -71,6 +71,7 @@ type User struct {
|
||||
DiscoverableByName bool `xorm:"bool default false index" json:"-"`
|
||||
DiscoverableByEmail bool `xorm:"bool default false index" json:"-"`
|
||||
OverdueTasksRemindersEnabled bool `xorm:"bool default true index" json:"-"`
|
||||
DefaultListForNewTasks int `xorm:"int default 1 index" json:"-"`
|
||||
|
||||
// A timestamp when this task was created. You cannot change this value.
|
||||
Created time.Time `xorm:"created not null" json:"created"`
|
||||
@ -371,6 +372,7 @@ func UpdateUser(s *xorm.Session, user *User) (updatedUser *User, err error) {
|
||||
"discoverable_by_name",
|
||||
"discoverable_by_email",
|
||||
"overdue_tasks_reminders_enabled",
|
||||
"default_list_for_new_tasks",
|
||||
).
|
||||
Update(user)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user