Added statements in constructor

This commit is contained in:
utkarshcmu 2015-11-20 04:37:24 -08:00
parent 93f9a0c39c
commit ca01604b43

View File

@ -43,7 +43,9 @@ func NewDashboard(title string) *Dashboard {
dash.Data = make(map[string]interface{}) dash.Data = make(map[string]interface{})
dash.Data["title"] = title dash.Data["title"] = title
dash.Title = title dash.Title = title
dash.UpdateSlug() dash.Created = time.Now()
dash.Updated = time.Now()
dash.UpdateSlug()
return dash return dash
} }
@ -66,19 +68,19 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard {
dash := &Dashboard{} dash := &Dashboard{}
dash.Data = data dash.Data = data
dash.Title = dash.Data["title"].(string) dash.Title = dash.Data["title"].(string)
dash.UpdateSlug() dash.UpdateSlug()
if dash.Data["id"] != nil { if dash.Data["id"] != nil {
dash.Id = int64(dash.Data["id"].(float64)) dash.Id = int64(dash.Data["id"].(float64))
if dash.Data["version"] != nil { if dash.Data["version"] != nil {
dash.Version = int(dash.Data["version"].(float64)) dash.Version = int(dash.Data["version"].(float64))
dash.Updated = time.Now() dash.Updated = time.Now()
} }
} else { } else {
dash.Data["version"] = 0 dash.Data["version"] = 0
dash.Created = time.Now() dash.Created = time.Now()
dash.Updated = time.Now() dash.Updated = time.Now()
} }
return dash return dash