feat: save user language in the settings
This commit is contained in:
parent
8bb3f8d37c
commit
a98119f2d6
7 changed files with 66 additions and 6 deletions
43
pkg/migration/20211212151642.go
Normal file
43
pkg/migration/20211212151642.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 user20211212151642 struct {
|
||||||
|
Language string `xorm:"varchar(50) null" json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (user20211212151642) TableName() string {
|
||||||
|
return "users"
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
migrations = append(migrations, &xormigrate.Migration{
|
||||||
|
ID: "20211212151642",
|
||||||
|
Description: "Add user langauge field",
|
||||||
|
Migrate: func(tx *xorm.Engine) error {
|
||||||
|
return tx.Sync2(user20211212151642{})
|
||||||
|
},
|
||||||
|
Rollback: func(tx *xorm.Engine) error {
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -50,6 +50,8 @@ type UserSettings struct {
|
||||||
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.
|
// The day when the week starts for this user. 0 = sunday, 1 = monday, etc.
|
||||||
WeekStart int `json:"week_start"`
|
WeekStart int `json:"week_start"`
|
||||||
|
// The user's language
|
||||||
|
Language string `json:"language"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserAvatarProvider returns the currently set user avatar
|
// GetUserAvatarProvider returns the currently set user avatar
|
||||||
|
@ -177,6 +179,7 @@ func UpdateGeneralUserSettings(c echo.Context) error {
|
||||||
user.OverdueTasksRemindersEnabled = us.OverdueTasksRemindersEnabled
|
user.OverdueTasksRemindersEnabled = us.OverdueTasksRemindersEnabled
|
||||||
user.DefaultListID = us.DefaultListID
|
user.DefaultListID = us.DefaultListID
|
||||||
user.WeekStart = us.WeekStart
|
user.WeekStart = us.WeekStart
|
||||||
|
user.Language = us.Language
|
||||||
|
|
||||||
_, err = user2.UpdateUser(s, user)
|
_, err = user2.UpdateUser(s, user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -73,6 +73,7 @@ func UserShow(c echo.Context) error {
|
||||||
OverdueTasksRemindersEnabled: u.OverdueTasksRemindersEnabled,
|
OverdueTasksRemindersEnabled: u.OverdueTasksRemindersEnabled,
|
||||||
DefaultListID: u.DefaultListID,
|
DefaultListID: u.DefaultListID,
|
||||||
WeekStart: u.WeekStart,
|
WeekStart: u.WeekStart,
|
||||||
|
Language: u.Language,
|
||||||
},
|
},
|
||||||
DeletionScheduledAt: u.DeletionScheduledAt,
|
DeletionScheduledAt: u.DeletionScheduledAt,
|
||||||
IsLocalUser: u.Issuer == user.IssuerLocal,
|
IsLocalUser: u.Issuer == user.IssuerLocal,
|
||||||
|
|
|
@ -8966,6 +8966,10 @@ var doc = `{
|
||||||
"description": "If enabled, sends email reminders of tasks to the user.",
|
"description": "If enabled, sends email reminders of tasks to the user.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"language": {
|
||||||
|
"description": "The user's language",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"description": "The new name of the current user.",
|
"description": "The new name of the current user.",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|
|
@ -8950,6 +8950,10 @@
|
||||||
"description": "If enabled, sends email reminders of tasks to the user.",
|
"description": "If enabled, sends email reminders of tasks to the user.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"language": {
|
||||||
|
"description": "The user's language",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"description": "The new name of the current user.",
|
"description": "The new name of the current user.",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|
|
@ -1274,6 +1274,9 @@ definitions:
|
||||||
email_reminders_enabled:
|
email_reminders_enabled:
|
||||||
description: If enabled, sends email reminders of tasks to the user.
|
description: If enabled, sends email reminders of tasks to the user.
|
||||||
type: boolean
|
type: boolean
|
||||||
|
language:
|
||||||
|
description: The user's language
|
||||||
|
type: string
|
||||||
name:
|
name:
|
||||||
description: The new name of the current user.
|
description: The new name of the current user.
|
||||||
type: string
|
type: string
|
||||||
|
|
|
@ -88,12 +88,13 @@ type User struct {
|
||||||
Issuer string `xorm:"text null" json:"-"`
|
Issuer string `xorm:"text null" json:"-"`
|
||||||
Subject string `xorm:"text null" json:"-"`
|
Subject string `xorm:"text null" json:"-"`
|
||||||
|
|
||||||
EmailRemindersEnabled bool `xorm:"bool default true" json:"-"`
|
EmailRemindersEnabled bool `xorm:"bool default true" json:"-"`
|
||||||
DiscoverableByName bool `xorm:"bool default false index" json:"-"`
|
DiscoverableByName bool `xorm:"bool default false index" json:"-"`
|
||||||
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:"-"`
|
WeekStart int `xorm:"null" json:"-"`
|
||||||
|
Language string `xorm:"varchar(50) null" json:"-"`
|
||||||
|
|
||||||
DeletionScheduledAt time.Time `xorm:"datetime null" json:"-"`
|
DeletionScheduledAt time.Time `xorm:"datetime null" json:"-"`
|
||||||
DeletionLastReminderSent time.Time `xorm:"datetime null" json:"-"`
|
DeletionLastReminderSent time.Time `xorm:"datetime null" json:"-"`
|
||||||
|
@ -477,6 +478,7 @@ func UpdateUser(s *xorm.Session, user *User) (updatedUser *User, err error) {
|
||||||
"overdue_tasks_reminders_enabled",
|
"overdue_tasks_reminders_enabled",
|
||||||
"default_list_id",
|
"default_list_id",
|
||||||
"week_start",
|
"week_start",
|
||||||
|
"language",
|
||||||
).
|
).
|
||||||
Update(user)
|
Update(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue