Merge branch 'master' into alerting_definitions

This commit is contained in:
bergquist
2016-04-25 16:42:33 +02:00
4 changed files with 49 additions and 12 deletions
+22
View File
@@ -1,7 +1,9 @@
package models
import (
"encoding/json"
"errors"
"fmt"
"time"
)
@@ -37,6 +39,26 @@ func (r RoleType) Includes(other RoleType) bool {
return r == other
}
func (r *RoleType) UnmarshalJSON(data []byte) error {
var str string
err := json.Unmarshal(data, &str)
if err != nil {
return err
}
*r = RoleType(str)
if (*r).IsValid() == false {
if (*r) != "" {
return errors.New(fmt.Sprintf("JSON validation error: invalid role value: %s", *r))
}
*r = ROLE_VIEWER
}
return nil
}
type OrgUser struct {
Id int64
OrgId int64