mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
refactoring: renaming
This commit is contained in:
parent
aaf2a897b0
commit
e290015887
@ -38,7 +38,7 @@ func PostDashboardAcl(c *middleware.Context, cmd m.SetDashboardAclCommand) Respo
|
||||
cmd.DashboardId = dashId
|
||||
|
||||
if err := bus.Dispatch(&cmd); err != nil {
|
||||
if err == m.ErrDashboardPermissionUserOrUserGroupEmpty {
|
||||
if err == m.ErrDashboardAclInfoMissing {
|
||||
return ApiError(409, err.Error(), err)
|
||||
}
|
||||
return ApiError(500, "Failed to create permission", err)
|
||||
|
@ -24,21 +24,21 @@ func (p PermissionType) String() string {
|
||||
|
||||
// Typed errors
|
||||
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
|
||||
type DashboardAcl struct {
|
||||
Id int64 `json:"id"`
|
||||
OrgId int64 `json:"-"`
|
||||
DashboardId int64 `json:"dashboardId"`
|
||||
Id int64
|
||||
OrgId int64
|
||||
DashboardId int64
|
||||
|
||||
Created time.Time `json:"created"`
|
||||
Updated time.Time `json:"updated"`
|
||||
UserId int64
|
||||
UserGroupId int64
|
||||
Permissions PermissionType
|
||||
|
||||
UserId int64 `json:"userId"`
|
||||
UserGroupId int64 `json:"userGroupId"`
|
||||
Permissions PermissionType `json:"permissions"`
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
}
|
||||
|
||||
type DashboardAclInfoDTO struct {
|
||||
|
@ -17,7 +17,7 @@ func init() {
|
||||
func SetDashboardAcl(cmd *m.SetDashboardAclCommand) error {
|
||||
return inTransaction(func(sess *DBSession) error {
|
||||
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 {
|
||||
|
@ -22,7 +22,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
|
||||
DashboardId: savedFolder.Id,
|
||||
Permissions: m.PERMISSION_EDIT,
|
||||
})
|
||||
So(err, ShouldEqual, m.ErrDashboardPermissionUserOrUserGroupEmpty)
|
||||
So(err, ShouldEqual, m.ErrDashboardAclInfoMissing)
|
||||
})
|
||||
|
||||
Convey("Given dashboard folder permission", func() {
|
||||
|
Loading…
Reference in New Issue
Block a user