Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b4576edc
Commit
b4576edc
authored
May 24, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: fix after upstream sqlstore refactoring
parent
764d25f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
11 deletions
+8
-11
pkg/services/sqlstore/dashboard_acl.go
+2
-3
pkg/services/sqlstore/user_group.go
+6
-8
No files found.
pkg/services/sqlstore/dashboard_acl.go
View file @
b4576edc
...
...
@@ -3,7 +3,6 @@ package sqlstore
import
(
"time"
"github.com/go-xorm/xorm"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
)
...
...
@@ -15,7 +14,7 @@ func init() {
}
func
AddOrUpdateDashboardPermission
(
cmd
*
m
.
AddOrUpdateDashboardPermissionCommand
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
return
inTransaction
(
func
(
sess
*
DB
Session
)
error
{
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
{
return
err
}
else
if
len
(
res
)
==
1
{
...
...
@@ -67,7 +66,7 @@ func AddOrUpdateDashboardPermission(cmd *m.AddOrUpdateDashboardPermissionCommand
}
func
RemoveDashboardPermission
(
cmd
*
m
.
RemoveDashboardPermissionCommand
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
return
inTransaction
(
func
(
sess
*
DB
Session
)
error
{
var
rawSQL
=
"DELETE FROM "
+
dialect
.
Quote
(
"dashboard_acl"
)
+
" WHERE dashboard_id =? and (user_group_id=? or user_id=?)"
_
,
err
:=
sess
.
Exec
(
rawSQL
,
cmd
.
DashboardId
,
cmd
.
UserGroupId
,
cmd
.
UserId
)
if
err
!=
nil
{
...
...
pkg/services/sqlstore/user_group.go
View file @
b4576edc
...
...
@@ -4,8 +4,6 @@ import (
"fmt"
"time"
"github.com/go-xorm/xorm"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
)
...
...
@@ -24,7 +22,7 @@ func init() {
}
func
CreateUserGroup
(
cmd
*
m
.
CreateUserGroupCommand
)
error
{
return
inTransaction
2
(
func
(
sess
*
s
ession
)
error
{
return
inTransaction
(
func
(
sess
*
DBS
ession
)
error
{
if
isNameTaken
,
err
:=
isUserGroupNameTaken
(
cmd
.
Name
,
0
,
sess
);
err
!=
nil
{
return
err
...
...
@@ -48,7 +46,7 @@ func CreateUserGroup(cmd *m.CreateUserGroupCommand) error {
}
func
UpdateUserGroup
(
cmd
*
m
.
UpdateUserGroupCommand
)
error
{
return
inTransaction
2
(
func
(
sess
*
s
ession
)
error
{
return
inTransaction
(
func
(
sess
*
DBS
ession
)
error
{
if
isNameTaken
,
err
:=
isUserGroupNameTaken
(
cmd
.
Name
,
cmd
.
Id
,
sess
);
err
!=
nil
{
return
err
...
...
@@ -76,7 +74,7 @@ func UpdateUserGroup(cmd *m.UpdateUserGroupCommand) error {
}
func
DeleteUserGroup
(
cmd
*
m
.
DeleteUserGroupCommand
)
error
{
return
inTransaction
2
(
func
(
sess
*
s
ession
)
error
{
return
inTransaction
(
func
(
sess
*
DBS
ession
)
error
{
if
res
,
err
:=
sess
.
Query
(
"SELECT 1 from user_group WHERE id=?"
,
cmd
.
Id
);
err
!=
nil
{
return
err
}
else
if
len
(
res
)
!=
1
{
...
...
@@ -98,7 +96,7 @@ func DeleteUserGroup(cmd *m.DeleteUserGroupCommand) error {
})
}
func
isUserGroupNameTaken
(
name
string
,
existingId
int64
,
sess
*
s
ession
)
(
bool
,
error
)
{
func
isUserGroupNameTaken
(
name
string
,
existingId
int64
,
sess
*
DBS
ession
)
(
bool
,
error
)
{
var
userGroup
m
.
UserGroup
exists
,
err
:=
sess
.
Where
(
"name=?"
,
name
)
.
Get
(
&
userGroup
)
...
...
@@ -179,7 +177,7 @@ func GetUserGroupsByUser(query *m.GetUserGroupsByUserQuery) error {
}
func
AddUserGroupMember
(
cmd
*
m
.
AddUserGroupMemberCommand
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
return
inTransaction
(
func
(
sess
*
DB
Session
)
error
{
if
res
,
err
:=
sess
.
Query
(
"SELECT 1 from user_group_member WHERE user_group_id=? and user_id=?"
,
cmd
.
UserGroupId
,
cmd
.
UserId
);
err
!=
nil
{
return
err
}
else
if
len
(
res
)
==
1
{
...
...
@@ -206,7 +204,7 @@ func AddUserGroupMember(cmd *m.AddUserGroupMemberCommand) error {
}
func
RemoveUserGroupMember
(
cmd
*
m
.
RemoveUserGroupMemberCommand
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
return
inTransaction
(
func
(
sess
*
DB
Session
)
error
{
var
rawSql
=
"DELETE FROM user_group_member WHERE user_group_id=? and user_id=?"
_
,
err
:=
sess
.
Exec
(
rawSql
,
cmd
.
UserGroupId
,
cmd
.
UserId
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment