Add default list setting #875

Merged
konrad merged 6 commits from sytone/api:main into main 2021-06-02 21:20:23 +00:00
13 changed files with 13 additions and 38 deletions
Showing only changes of commit 302064b4bb - Show all commits

View File

@ -22,7 +22,7 @@ import (
)
type users20210527105701 struct {
DefaultListForNewTasks int `xorm:"int default 1 index" json:"-"`
DefaultListID int64 `xorm:"bigint null index" json:"-"`

A few things:

  • This should be an int64 as all other ids are. Same for the xorm tag (I think that is bigint, take a look at the other ID fields).
  • Please make the field nullable and remove the default value. That will also remove the need to update all the tests.
  • I think the field would be better named something like DefaultListID - that way it's clear what this is.
A few things: * This should be an `int64` as all other ids are. Same for the xorm tag (I think that is bigint, take a look at the other ID fields). * Please make the field nullable and remove the default value. That will also remove the need to update all the tests. * I think the field would be better named something like `DefaultListID` - that way it's clear what this is.

Updated and renames, tests updated.

Updated and renames, tests updated.
}
func (users20210527105701) TableName() string {

View File

@ -75,7 +75,6 @@ func TestLabelTask_ReadAll(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
},

View File

@ -55,7 +55,6 @@ func TestLabel_ReadAll(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -106,7 +105,6 @@ func TestLabel_ReadAll(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
},
@ -172,7 +170,6 @@ func TestLabel_ReadOne(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -234,7 +231,6 @@ func TestLabel_ReadOne(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
},

View File

@ -184,7 +184,6 @@ func TestListUser_ReadAll(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
},
@ -198,7 +197,6 @@ func TestListUser_ReadAll(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
},

View File

@ -183,7 +183,6 @@ func TestNamespaceUser_ReadAll(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
},
@ -197,7 +196,6 @@ func TestNamespaceUser_ReadAll(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
},

View File

@ -38,7 +38,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -49,7 +48,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -61,7 +59,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
IsActive: true,
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}

View File

@ -33,7 +33,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -44,7 +43,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -56,7 +54,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -69,7 +66,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -82,7 +78,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -94,7 +89,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -107,7 +101,6 @@ func TestListUsersFromList(t *testing.T) {
EmailRemindersEnabled: true,
DiscoverableByEmail: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -119,7 +112,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -131,7 +123,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -143,7 +134,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -156,7 +146,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -170,7 +159,6 @@ func TestListUsersFromList(t *testing.T) {
EmailRemindersEnabled: true,
DiscoverableByName: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}
@ -182,7 +170,6 @@ func TestListUsersFromList(t *testing.T) {
Issuer: "local",
EmailRemindersEnabled: true,
OverdueTasksRemindersEnabled: true,
DefaultListForNewTasks: 1,
Created: testCreatedTime,
Updated: testUpdatedTime,
}

View File

@ -47,7 +47,7 @@ type UserSettings struct {
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"`
DefaultListID int64 `json:"default_list_id"`

Should be int64 as well.

Should be `int64` as well.

Updated to match.

Updated to match.
}
// GetUserAvatarProvider returns the currently set user avatar
@ -173,7 +173,7 @@ func UpdateGeneralUserSettings(c echo.Context) error {
user.DiscoverableByEmail = us.DiscoverableByEmail
user.DiscoverableByName = us.DiscoverableByName
user.OverdueTasksRemindersEnabled = us.OverdueTasksRemindersEnabled
user.DefaultListForNewTasks = us.DefaultListForNewTasks
user.DefaultListID = us.DefaultListID
_, err = user2.UpdateUser(s, user)
if err != nil {

View File

@ -68,7 +68,7 @@ func UserShow(c echo.Context) error {
DiscoverableByName: u.DiscoverableByName,
DiscoverableByEmail: u.DiscoverableByEmail,
OverdueTasksRemindersEnabled: u.OverdueTasksRemindersEnabled,
DefaultListForNewTasks: u.DefaultListForNewTasks,
DefaultListID: u.DefaultListID,
},
}

View File

@ -8556,7 +8556,7 @@ var doc = `{
"v1.UserSettings": {
"type": "object",
"properties": {
"default_list_for_new_tasks": {
"default_list_id": {
"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"
},

View File

@ -8539,7 +8539,7 @@
"v1.UserSettings": {
"type": "object",
"properties": {
"default_list_for_new_tasks": {
"default_list_id": {
"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"
},

View File

@ -1178,7 +1178,7 @@ definitions:
type: object
v1.UserSettings:
properties:
default_list_for_new_tasks:
default_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.

View File

@ -67,11 +67,11 @@ type User struct {
Issuer string `xorm:"text null" json:"-"`
Subject string `xorm:"text null" json:"-"`
EmailRemindersEnabled bool `xorm:"bool default true" json:"-"`
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:"-"`
EmailRemindersEnabled bool `xorm:"bool default true" json:"-"`
DiscoverableByName bool `xorm:"bool default false index" json:"-"`
DiscoverableByEmail bool `xorm:"bool default false index" json:"-"`
OverdueTasksRemindersEnabled bool `xorm:"bool default true index" json:"-"`
DefaultListID int64 `xorm:"bigint null index" json:"-"`

Please see the comments on the migration.

Please see the comments on the migration.

Updated to match migraiton, now null by default, bigint which maps to int64 as verified in the xorm documents.

Updated to match migraiton, now null by default, bigint which maps to int64 as verified in the xorm documents.
// A timestamp when this task was created. You cannot change this value.
Created time.Time `xorm:"created not null" json:"created"`
@ -372,7 +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",
"default_list_id",
).
Update(user)
if err != nil {