Set active account now works again

This commit is contained in:
Torkel Ödegaard
2014-12-15 21:56:16 +01:00
parent 973b9cad36
commit 705455d5d6
8 changed files with 49 additions and 36 deletions
+1 -1
View File
@@ -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
+9 -5
View File
@@ -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 {
+1 -1
View File
@@ -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 {