Set active account now works again
This commit is contained in:
@@ -29,7 +29,7 @@ var (
|
||||
func Init() {
|
||||
tables = append(tables, new(models.Account), new(models.Dashboard), new(models.Collaborator))
|
||||
|
||||
models.CreateAccount = CreateAccount
|
||||
models.SaveAccount = SaveAccount
|
||||
models.GetAccount = GetAccount
|
||||
models.GetAccountByLogin = GetAccountByLogin
|
||||
models.GetOtherAccountsFor = GetOtherAccountsFor
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package sqlstore
|
||||
|
||||
import (
|
||||
"github.com/torkelo/grafana-pro/pkg/models"
|
||||
)
|
||||
import "github.com/torkelo/grafana-pro/pkg/models"
|
||||
|
||||
func CreateAccount(account *models.Account) error {
|
||||
func SaveAccount(account *models.Account) error {
|
||||
var err error
|
||||
|
||||
sess := x.NewSession()
|
||||
@@ -14,7 +12,13 @@ func CreateAccount(account *models.Account) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err = sess.Insert(account); err != nil {
|
||||
if account.Id == 0 {
|
||||
_, err = sess.Insert(account)
|
||||
} else {
|
||||
_, err = sess.Id(account.Id).Update(account)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
sess.Rollback()
|
||||
return err
|
||||
} else if err = sess.Commit(); err != nil {
|
||||
|
||||
@@ -15,7 +15,7 @@ func SaveDashboard(dash *models.Dashboard) error {
|
||||
if dash.Id == 0 {
|
||||
_, err = sess.Insert(dash)
|
||||
} else {
|
||||
_, err = sess.Update(dash)
|
||||
_, err = sess.Id(dash.Id).Update(dash)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user