Add setting for first day of the week
This commit is contained in:
parent
fc5703ac8c
commit
78a206c818
7 changed files with 61 additions and 0 deletions
43
pkg/migration/20210603174608.go
Normal file
43
pkg/migration/20210603174608.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 users20210603174608 struct {
|
||||||
|
WeekStart int `xorm:"null" json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (users20210603174608) TableName() string {
|
||||||
|
return "users"
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
migrations = append(migrations, &xormigrate.Migration{
|
||||||
|
ID: "20210603174608",
|
||||||
|
Description: "Add week start user setting",
|
||||||
|
Migrate: func(tx *xorm.Engine) error {
|
||||||
|
return tx.Sync2(users20210603174608{})
|
||||||
|
},
|
||||||
|
Rollback: func(tx *xorm.Engine) error {
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -48,6 +48,8 @@ type UserSettings struct {
|
||||||
// If a task is created without a specified list this value should be used. Applies
|
// If a task is created without a specified list this value should be used. Applies
|
||||||
// to tasks made directly in API and from clients.
|
// to tasks made directly in API and from clients.
|
||||||
DefaultListID int64 `json:"default_list_id"`
|
DefaultListID int64 `json:"default_list_id"`
|
||||||
|
// The day when the week starts for this user. 0 = sunday, 1 = monday, etc.
|
||||||
|
WeekStart int `json:"week_start"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserAvatarProvider returns the currently set user avatar
|
// GetUserAvatarProvider returns the currently set user avatar
|
||||||
|
@ -174,6 +176,7 @@ func UpdateGeneralUserSettings(c echo.Context) error {
|
||||||
user.DiscoverableByName = us.DiscoverableByName
|
user.DiscoverableByName = us.DiscoverableByName
|
||||||
user.OverdueTasksRemindersEnabled = us.OverdueTasksRemindersEnabled
|
user.OverdueTasksRemindersEnabled = us.OverdueTasksRemindersEnabled
|
||||||
user.DefaultListID = us.DefaultListID
|
user.DefaultListID = us.DefaultListID
|
||||||
|
user.WeekStart = us.WeekStart
|
||||||
|
|
||||||
_, err = user2.UpdateUser(s, user)
|
_, err = user2.UpdateUser(s, user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -69,6 +69,7 @@ func UserShow(c echo.Context) error {
|
||||||
DiscoverableByEmail: u.DiscoverableByEmail,
|
DiscoverableByEmail: u.DiscoverableByEmail,
|
||||||
OverdueTasksRemindersEnabled: u.OverdueTasksRemindersEnabled,
|
OverdueTasksRemindersEnabled: u.OverdueTasksRemindersEnabled,
|
||||||
DefaultListID: u.DefaultListID,
|
DefaultListID: u.DefaultListID,
|
||||||
|
WeekStart: u.WeekStart,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8579,6 +8579,10 @@ var doc = `{
|
||||||
"overdue_tasks_reminders_enabled": {
|
"overdue_tasks_reminders_enabled": {
|
||||||
"description": "If enabled, the user will get an email for their overdue tasks each morning.",
|
"description": "If enabled, the user will get an email for their overdue tasks each morning.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"week_start": {
|
||||||
|
"description": "The day when the week starts for this user. 0 = sunday, 1 = monday, etc.",
|
||||||
|
"type": "integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -8562,6 +8562,10 @@
|
||||||
"overdue_tasks_reminders_enabled": {
|
"overdue_tasks_reminders_enabled": {
|
||||||
"description": "If enabled, the user will get an email for their overdue tasks each morning.",
|
"description": "If enabled, the user will get an email for their overdue tasks each morning.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"week_start": {
|
||||||
|
"description": "The day when the week starts for this user. 0 = sunday, 1 = monday, etc.",
|
||||||
|
"type": "integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1201,6 +1201,10 @@ definitions:
|
||||||
description: If enabled, the user will get an email for their overdue tasks
|
description: If enabled, the user will get an email for their overdue tasks
|
||||||
each morning.
|
each morning.
|
||||||
type: boolean
|
type: boolean
|
||||||
|
week_start:
|
||||||
|
description: The day when the week starts for this user. 0 = sunday, 1 = monday,
|
||||||
|
etc.
|
||||||
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
v1.authInfo:
|
v1.authInfo:
|
||||||
properties:
|
properties:
|
||||||
|
|
|
@ -72,6 +72,7 @@ type User struct {
|
||||||
DiscoverableByEmail bool `xorm:"bool default false index" json:"-"`
|
DiscoverableByEmail bool `xorm:"bool default false index" json:"-"`
|
||||||
OverdueTasksRemindersEnabled bool `xorm:"bool default true index" json:"-"`
|
OverdueTasksRemindersEnabled bool `xorm:"bool default true index" json:"-"`
|
||||||
DefaultListID int64 `xorm:"bigint null index" json:"-"`
|
DefaultListID int64 `xorm:"bigint null index" json:"-"`
|
||||||
|
WeekStart int `xorm:"null" json:"-"`
|
||||||
|
|
||||||
// A timestamp when this task was created. You cannot change this value.
|
// A timestamp when this task was created. You cannot change this value.
|
||||||
Created time.Time `xorm:"created not null" json:"created"`
|
Created time.Time `xorm:"created not null" json:"created"`
|
||||||
|
@ -373,6 +374,7 @@ func UpdateUser(s *xorm.Session, user *User) (updatedUser *User, err error) {
|
||||||
"discoverable_by_email",
|
"discoverable_by_email",
|
||||||
"overdue_tasks_reminders_enabled",
|
"overdue_tasks_reminders_enabled",
|
||||||
"default_list_id",
|
"default_list_id",
|
||||||
|
"week_start",
|
||||||
).
|
).
|
||||||
Update(user)
|
Update(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue