Commit e2900158 by Torkel Ödegaard

refactoring: renaming

parent aaf2a897
...@@ -38,7 +38,7 @@ func PostDashboardAcl(c *middleware.Context, cmd m.SetDashboardAclCommand) Respo ...@@ -38,7 +38,7 @@ func PostDashboardAcl(c *middleware.Context, cmd m.SetDashboardAclCommand) Respo
cmd.DashboardId = dashId cmd.DashboardId = dashId
if err := bus.Dispatch(&cmd); err != nil { if err := bus.Dispatch(&cmd); err != nil {
if err == m.ErrDashboardPermissionUserOrUserGroupEmpty { if err == m.ErrDashboardAclInfoMissing {
return ApiError(409, err.Error(), err) return ApiError(409, err.Error(), err)
} }
return ApiError(500, "Failed to create permission", err) return ApiError(500, "Failed to create permission", err)
......
...@@ -24,21 +24,21 @@ func (p PermissionType) String() string { ...@@ -24,21 +24,21 @@ func (p PermissionType) String() string {
// Typed errors // Typed errors
var ( var (
ErrDashboardPermissionUserOrUserGroupEmpty = errors.New("User id and user group id cannot both be empty for a dashboard permission.") ErrDashboardAclInfoMissing = errors.New("User id and user group id cannot both be empty for a dashboard permission.")
) )
// Dashboard ACL model // Dashboard ACL model
type DashboardAcl struct { type DashboardAcl struct {
Id int64 `json:"id"` Id int64
OrgId int64 `json:"-"` OrgId int64
DashboardId int64 `json:"dashboardId"` DashboardId int64
Created time.Time `json:"created"` UserId int64
Updated time.Time `json:"updated"` UserGroupId int64
Permissions PermissionType
UserId int64 `json:"userId"` Created time.Time
UserGroupId int64 `json:"userGroupId"` Updated time.Time
Permissions PermissionType `json:"permissions"`
} }
type DashboardAclInfoDTO struct { type DashboardAclInfoDTO struct {
......
...@@ -17,7 +17,7 @@ func init() { ...@@ -17,7 +17,7 @@ func init() {
func SetDashboardAcl(cmd *m.SetDashboardAclCommand) error { func SetDashboardAcl(cmd *m.SetDashboardAclCommand) error {
return inTransaction(func(sess *DBSession) error { return inTransaction(func(sess *DBSession) error {
if cmd.UserId == 0 && cmd.UserGroupId == 0 { if cmd.UserId == 0 && cmd.UserGroupId == 0 {
return m.ErrDashboardPermissionUserOrUserGroupEmpty return m.ErrDashboardAclInfoMissing
} }
if res, err := sess.Query("SELECT 1 from "+dialect.Quote("dashboard_acl")+" WHERE dashboard_id =? and (user_group_id=? or user_id=?)", cmd.DashboardId, cmd.UserGroupId, cmd.UserId); err != nil { if res, err := sess.Query("SELECT 1 from "+dialect.Quote("dashboard_acl")+" WHERE dashboard_id =? and (user_group_id=? or user_id=?)", cmd.DashboardId, cmd.UserGroupId, cmd.UserId); err != nil {
......
...@@ -22,7 +22,7 @@ func TestDashboardAclDataAccess(t *testing.T) { ...@@ -22,7 +22,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
DashboardId: savedFolder.Id, DashboardId: savedFolder.Id,
Permissions: m.PERMISSION_EDIT, Permissions: m.PERMISSION_EDIT,
}) })
So(err, ShouldEqual, m.ErrDashboardPermissionUserOrUserGroupEmpty) So(err, ShouldEqual, m.ErrDashboardAclInfoMissing)
}) })
Convey("Given dashboard folder permission", func() { Convey("Given dashboard folder permission", func() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment